Search code examples
pythonscheduled-taskscroncron-task

Non time-specific once a day crontab?


I have a python script, and I wish to run it once and only once everyday. I did some research on the crontab command, and it seems to do so, but at a fixed time each day. The issue is that my computer won't be on all day and a specific time for running it is just not possible. What can I do?

Could a log file help? I was thinking of doing a crontab every 5 minutes or so and scanning a log file to see any runs for the day.


Solution

  • Install anacron, a cron scheduler that'll handle tasks that run at most once a day when your computer is powered on.

    From the WikiPedia page:

    anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days) on systems that don't run 24 hours a day.