From owner-freebsd-questions@freebsd.org Tue Oct 18 14:17:17 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77F0DC16862 for ; Tue, 18 Oct 2016 14:17:17 +0000 (UTC) (envelope-from paul@ifdnrg.com) Received: from outbound.ifdnrg.com (outbound2.ifdnrg.com [193.200.98.38]) by mx1.freebsd.org (Postfix) with ESMTP id 27BB23A0 for ; Tue, 18 Oct 2016 14:17:16 +0000 (UTC) (envelope-from paul@ifdnrg.com) Received: from [192.168.1.109] (cpc103070-sgyl39-2-0-cust295.18-2.cable.virginm.net [82.33.151.40]) (authenticated bits=0) by outbound.ifdnrg.com (8.15.2/8.15.2) with ESMTPSA id u9IEHAcj038301 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Tue, 18 Oct 2016 15:17:11 +0100 (BST) (envelope-from paul@ifdnrg.com) X-Authentication-Warning: outbound.ifdnrg.com: Host cpc103070-sgyl39-2-0-cust295.18-2.cable.virginm.net [82.33.151.40] claimed to be [192.168.1.109] Subject: Re: pw add user slow To: freebsd-questions@freebsd.org References: <20161018074415.0f6575675db30d0b83d9b8ec@sohara.org> <60719.69.209.239.247.1476794773.squirrel@cosmo.uchicago.edu> <20161018140531.GA1080@lime.woodcruft.co.uk> From: Paul Macdonald Message-ID: Date: Tue, 18 Oct 2016 15:17:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161018140531.GA1080@lime.woodcruft.co.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2016 14:17:17 -0000 On 18/10/2016 15:05, Frank Shute wrote: > On Tue, Oct 18, 2016 at 07:46:13AM -0500, Valeri Galtsev wrote: >> >> On Tue, October 18, 2016 1:44 am, Steve O'Hara-Smith wrote: >>> On Mon, 17 Oct 2016 23:36:33 +0100 >>> Paul Macdonald wrote: >>> >>>> Hi, >>>> >>>> I have to migrate an imap server, which uses about 6000 local accounts >>>> for mail delivery >>>> >>>> I'm using a script that creates system acounts using: >>>> >>>> /usr/sbin/pw adduser $LOCAL_USER -u$UID-gGID-d $PATH -s/bin/false >>>> >>>> I'm finding this grows ever more slow, up to 10 seconds per account on a >>>> SATA box , and on a test SSD box ( 20 acc's per second initially) even >>>> that slows to about 1 account created per second. >>>> >>>> why does this slow down as more accounts are added? >>> Because for each one it updates text files (passwd and >>> master.passwd) and regenerates databases (pwd.db and spwd.db) from the >>> text >>> files. The fastest way to do this sort of thing is to directly update >>> passwd and master.passwd and then run pwd_mkdb. >> It appears to be sufficient to only edit master.passwd; pwd_mkdb will >> re-generate passwd file from master.passwd. >> > There's a tool for that: vipw(8) > > It uses $EDITOR if set, vi as default. > > If using vi/vim then fire up vipw and: > > :r!myscript > > will stick stdout from myscript into the buffer where the cursor is. Then: > > :wq > > and vipw will write it if it's conformant and then call pwd_mkdb to do it's > business. > > The OP will also have to edit /etc/group to add his users to the appropriate > group(s). > > Doesn't the imap server have an option for using a relational database rather > than filling passwd up? I'd go for that option if it does. > > > Regards, > manually writing to the master passwd and running pwd_mkdb was a lot quicker, thanks at 10 seconds per account, 6500 would take a long time... (16hrs!) the system accounts are for sendmail delivery to mailboxes, possibly a good time to take a look at exim/postfix. thanks Paul -- ------------------------- Paul Macdonald IFDNRG Ltd Web and video hosting ------------------------- t: 0131 5548070 m: 07970339546 e: paul@ifdnrg.com w: http://www.ifdnrg.com ------------------------- IFDNRG 40 Maritime Street Edinburgh EH6 6SA ---------------------------------------------------- Virtual Servers from £50.00pm High specification Dedicated Servers from £150.00pm ----------------------------------------------------