I am running my Python script using upstart feature of Ubuntu so that if for whatever reason my Python script dies or gets killed, it can be restarted automatically and everything is working fine -
So I decided to use UPSTART
feature of Ubuntu to restart the Python script automatically.
After creating the testing.conf
file like this in /etc/init/testing.conf
-
start on runlevel [2345]
stop on runlevel [016]
chdir /tekooz
exec python testing.py
respawn
I ran below sudo command to start it and I can see that process running using ps ax
and my python script is also running fine.
root@bx13:/tekooz# sudo start testing
testing start/running, process 27794
Now if I kill the PID of the above process, then it get restarted automatically within few milliseconds or microseconds.
Is there any possibility of restarting my python script after 1 second if it has gone down or got killed? I don't want to restart immediately.