Running process on startup as a user

Eric Crist mnslinky at gmail.com
Thu Sep 13 18:58:10 PDT 2007


On Sep 13, 2007, at 1:15 PMSep 13, 2007, Jack Barnett wrote:

>
> Using FreeBSD 6.2 x86.
>
> I have a script called:
>
> /home/foo/scripts/MyScript.sh
> The user is 'foo'.  The password is 'bar'.
>
> What I'm trying to do is run the MyScript.sh command on startup  
> (that way if the box reboots, then this users process also re- 
> starts it's self).
>
> thoughts?
>

/etc/crontab allows you to actually specify the user to run the  
process as in the 6th field.  An entry such as:

@reboot     foo     /home/foo/scripts/MyScript.sh

Would work for running the process at startup.  The following entry  
is an example for running a script as user for every Monday on 3pm:

00     03    *     *     1     foo     /home/foo/scripts/MyScript.sh

And, as others have already said, you can just put the following  
entry in user foo's crontab:
* Note, you can access that user's crontab by loggin in as that user  
and typing "crontab -e", or as root by typing "crontab -e -u foo":

@reboot     /home/foo/scripts/MyScript.sh

HTH
-----
Eric F Crist
Secure Computing Networks




More information about the freebsd-questions mailing list