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.
~/.config/upstart/
so that you don't needsudo
: you would useinitctl start testing
to start the script for example. (I am assuming that your conf file doesn't need root privileges.)sudo start testing
. In your example you told me I can place the file in~/.config/upstart/
folder but I am not able to find this folder? Can you provide me the full path where I can put my file?.config
directory. Inside.config
, you need to create a folder namedupstart
(that is, if it doesn't exist just create it).