I'm running a Python program on my Linux server, and depending on some external data it has to run again at xx
minutes or hours from now.
So let's say it runs at 6 AM, and then it has to run again at 7 AM. Then, at 7AM, it checks some things and it has to run again at 15:45, and then the next day at 2.05AM, and then the next day at 4.05AM etc.
As you can see there is no predefined logic in the times it has to run, it has to be defined at the time it runs.
The only task schedule mechanism I know is crontab
, bu I'm not sure how to add tasks to it without running crontab -e
and besides that crontab
seems more for recurring tasks and in my case I would add a crontab
job and after running it once remove it again and add a new one.
The only thing I could come up with was to set the next rundate in a textfile, and let a crontab
job check it every minute to see if it is time to run the program.