I use free AWS instance running Ubuntu 14.04 and run python script there. I would like to have this python script started with each Ubuntu reboot, so I've edited /etc/rc.local
and added the following lines there:
cd ~/myappfolder
while true; do timeout 1h python worker.py --log-level=ERROR; done
exit 0
But it doesn't work. What could be wrong here?
You can also use
crontab
for this.Create a .sh file and save it. (For example to /etc/myscript.sh) Test run it. If you get a Permission Denied error run
chmod +x /etc/myscript.sh
Then run these commands:
Those commands insert the last line into crontab so it runs everytime you reboot.