So I have a python script that I launch in the terminal by just typing the script name (python SCRIPTNAME.py)
I'm just wondering is it possible to make a script or cron job that simply just stops then starts that python script every hour?
cronpython
So I have a python script that I launch in the terminal by just typing the script name (python SCRIPTNAME.py)
I'm just wondering is it possible to make a script or cron job that simply just stops then starts that python script every hour?
Best Answer
Best approach would be via GNU
timeout
as inwhere -k stands for "kill after" and time in seconds.
So to have the script run, terminate and restart every hour, you could do
where
sleep 2
is merely to add small delay before restartingAlternatively consider using Threading module in Python to schedule the relevant parts of the script instead. See https://stackoverflow.com/a/50537798/3701431