I have a python script which I am running like this as shown below:
python3 ./bin/abc.py --log_file ./web/prr.log
Now I need to make sure that above process runs after every 3 hours. Below is the flow:
- If the process is running already, then kill the process and sleep for 3 hours.
- After sleeping for 3 hours, if process is not running, start the process again by executing above python command and then sleep for three hours.
- Repeat the above process.
So meaning, I need to make sure that my process is running every alternate 3 hours so I need to find a way to kill the process after every 3 hours. I was thinking to use watch
command here but not sure how can I use it here. I am working with Ubuntu 14.
Note: I can't modify the python script so I need to do it from outside of it.
See Question&Answers more detail:os