[NCLUG] starting a script at startup as specific user?
Mark Fassler
fassler at monkeysoft.net
Fri Apr 27 01:27:31 MDT 2001
On Thu, Apr 26, 2001 at 11:44:06PM -0600, Gordon Forsythe wrote:
> Hi everyone...can someone tell me a simple way to have a script run as a
> specific user when the box boots? httpd runs as apache, so I am trying to
> figure out a way to do this for other things. A friend told me to check
> init.d and rc.d...httpd is in init.d, but I do not see where in the script
> the user is specified. I may be looking at this from the wrong angle too.
> Thanks in advance!
> Gordon
Apache actually starts as root, then becomes another user; who this other
user is is set in httpd.conf, so that's rather specific to apache.
If you're using RedHat, take a look at how named starts up:
daemon named -u named
the "-u" argument specifies the user to start as.
The "daemon" command isn't a normal bash command, but comes from
/etc/rc.d/init.d/functions (again, I'm assuming RedHat). You might want
to use /etc/rc.d/init.d/named as an example.
Whether or not you're using RedHat, you can also do something simple like
this:
su user -c command_to_run
(This is essentially what the daemon() function does.)
--
Mark Fassler
fassler at monkeysoft.net
More information about the NCLUG
mailing list