thomasfedb Asked: 2010-07-19 07:21:56 +0800 CST2010-07-19 07:21:56 +0800 CST 2010-07-19 07:21:56 +0800 CST Start ruby script at boot as particular user 772 wondering how I can have a ruby script started at boot, as a particular user. This is on centos, so I imagine i need to create a service. ? centos service ruby users god 3 Answers Voted Gilles 'SO- stop being evil' 2010-07-19T08:34:49+08:002010-07-19T08:34:49+08:00 If you just want to run this script at boot time, put it in that user's crontab with the special time @reboot. If the script is a long-running process that would normally keep running until you reboot, then a adding a service is the best solution. Best Answer Ignacio Vazquez-Abrams 2010-07-19T07:24:16+08:002010-07-19T07:24:16+08:00 Read /usr/share/doc/initscripts-*/sysvinitfiles for information on writing the initscript that you'll need for this. lurtz 2010-07-19T07:38:11+08:002010-07-19T07:38:11+08:00 Or u can add to /etc/rc.local somthing like this: /usr/bin/sudo -u $user /path/to/script/script.rb
If you just want to run this script at boot time, put it in that user's crontab with the special time
@reboot
.If the script is a long-running process that would normally keep running until you reboot, then a adding a service is the best solution.
Read
/usr/share/doc/initscripts-*/sysvinitfiles
for information on writing the initscript that you'll need for this.Or u can add to /etc/rc.local somthing like this:
/usr/bin/sudo -u $user /path/to/script/script.rb