I have a server which exists to run one little Django application. If the server reboots, I want Django to start again:
nohup /opt/myapp/manage.py runserver ...
I'm having trouble finding a simple way to make this run. There are tutorials explaining how to write full-fledged services, runlevels, init.d etc. But there must be a simpler way? A place where I can hack this one extra line onto?
EDIT Mark's answer is perfect, the one-liner works out as:
sudo sed --in-place '/^exit 0/i\cd /opt/appdir\npython manage.py runserver .... &' /etc/rc.local
You could add it to
/etc/rc.local
before the line that saysexit 0
. This way it will run at boot every time.To add the command using one line: