Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Dec 2005 11:16:42 +0000
From:      Scott Mitchell <scott+lists.freebsd@fishballoon.org>
To:        Ian Lord <mailing-lists@msdi.ca>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: schedule a script at "system startup"
Message-ID:  <20051204111642.GA933@tuatara.fishballoon.org>
In-Reply-To: <7.0.0.16.2.20051203115712.054a1c70@msdi.ca>
References:  <7.0.0.16.2.20051203115712.054a1c70@msdi.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051204111642.GA933>