From owner-freebsd-questions@FreeBSD.ORG Sun Dec 4 11:17:07 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 570C816A41F for ; Sun, 4 Dec 2005 11:17:07 +0000 (GMT) (envelope-from scott@fishballoon.org) Received: from mta09-winn.ispmail.ntl.com (mta09-winn.ispmail.ntl.com [81.103.221.49]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88E6043D92 for ; Sun, 4 Dec 2005 11:16:59 +0000 (GMT) (envelope-from scott@fishballoon.org) Received: from aamta11-winn.ispmail.ntl.com ([81.103.221.35]) by mta09-winn.ispmail.ntl.com with ESMTP id <20051204111657.LEML8609.mta09-winn.ispmail.ntl.com@aamta11-winn.ispmail.ntl.com>; Sun, 4 Dec 2005 11:16:57 +0000 Received: from llama.fishballoon.org ([81.104.195.171]) by aamta11-winn.ispmail.ntl.com with ESMTP id <20051204111657.WAUM16192.aamta11-winn.ispmail.ntl.com@llama.fishballoon.org>; Sun, 4 Dec 2005 11:16:57 +0000 Received: from tuatara.fishballoon.org ([192.168.1.6]) by llama.fishballoon.org with esmtp (Exim 4.52 (FreeBSD)) id 1EirrT-000LJb-It; Sun, 04 Dec 2005 11:16:55 +0000 Received: (from scott@localhost) by tuatara.fishballoon.org (8.13.3/8.13.3/Submit) id jB4BGgIc010375; Sun, 4 Dec 2005 11:16:42 GMT (envelope-from scott) Date: Sun, 4 Dec 2005 11:16:42 +0000 From: Scott Mitchell To: Ian Lord Message-ID: <20051204111642.GA933@tuatara.fishballoon.org> References: <7.0.0.16.2.20051203115712.054a1c70@msdi.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7.0.0.16.2.20051203115712.054a1c70@msdi.ca> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE i386 Cc: freebsd-questions@freebsd.org Subject: Re: schedule a script at "system startup" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2005 11:17:07 -0000 On Sat, Dec 03, 2005 at 08:18:12PM -0500, Ian Lord wrote: > Hi, > > I would like to run a shell script at system startup which needs to > run under a specific uid... > > I don't see anything for this in man cron... Try 'man 5 crontab' - there's an @reboot string that can be used instead of the normal time specification in a crontab file to have the command run once at startup (of the cron daemon, presumably). > is there a way to do it with cron ? or otherwise is there another way ? > > I guess there might be a way to put a script in /etc/rd.d/ but I > don't know how to run it under a specifid uid Your rc.d script could just use 'su' to switch to the desired user and execute another script as that user: su - someuser -c /path/to/some/script su passes everything after the username as arguments to the shell running as someuser. I guess the advantage of running your script out of /etc/rc.d is that you can control when it gets run relative to all the other startup scripts - 'man rcorder' for details on this. Cheers, Scott -- =========================================================================== Scott Mitchell | PGP Key ID | "Eagles may soar, but weasels Cambridge, England | 0x54B171B9 | don't get sucked into jet engines" scott at fishballoon.org | 0xAA775B8B | -- Anon