I am new to python and have pretty basic knowledge of Linux.
I need to start a script at boot time on a Ubuntu 14.04.3 server.
The only thing is, the script is a monitoring tool and should be running all the time so I can't just make a periodical cron call.
I found this at first : running a python script with cron
I have tried to add this in crontab :
@reboot python /path/to/script.py &
And also this :
@reboot /path/to/script.py &
but it doesn't seems to work.
I have also seen this : How to make a python script run like a service or daemon in linux
The main answer is cron or a change in the python code.
So my question is : Is there another way to run my script at boot and let it run "forever" without changing the code ?
I assure you if I don't want to change the code it's not by lazyness but I will if it's the only option.
Other information (don't know if it's necessary), I am running Windows and have access to the server via PuTTY. The version of Python is 2.7
UPDATE
Here is the cron log :
Nov 27 15:57:03 trustyovh cron[760]: (CRON) INFO (pidfile fd = 3)
Nov 27 15:57:03 trustyovh cron[798]: (CRON) STARTUP (fork ok)
Nov 27 15:57:03 trustyovh cron[798]: (CRON) INFO (Running @reboot jobs)
Nov 27 15:57:03 trustyovh CRON[807]: (administrateur) CMD (/home/administrateur/scuMonitor/main.py &)
Nov 27 15:57:03 trustyovh CRON[800]: (CRON) info (No MTA installed, discarding output)
Nov 27 16:09:01 trustyovh CRON[1792]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Here is the crontab :
@reboot /home/administrateur/scuMonitor/main.py &
UPDATE 2
Well, it was actually working with the cron set to reboot, but, my script didn't put his log where I expected it to do (I wasn't understanding how the path work on Linux).
Thanks for all the answers everyone !