I am using Arch Linux.
I need to start my web application automatically should the server should restart. I need to run it as user 'www'.
How can I do this?
I am using Arch Linux.
I need to start my web application automatically should the server should restart. I need to run it as user 'www'.
How can I do this?
You need to write an init script for your web application. (Examples for Dropbox and RTorrent. You can find more examples if you search the wiki for add_daemon
.)
Your script would use su
to run the application as the appropriate user. (Init scripts run as root, so they can su
to any user.)
The critical line would look something like
su www -c "/path/of/app &"
Then you would add your new daemon to the DAEMONS list in /etc/rc.conf
, so it will be started automatically after booting.
Use su
to run it as the user, and put it into your /etc/rc.local
to run it at boot.
su -c "start_server" www &
www
you could use:sudo -u www some_command
. – Mar 17 '12 at 16:47