Depending on your
cron implementation you may be able to use
Instead of the first five fields, one of eight special strings may
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
I'm not sure how
cron will deal with
@daily if your computer is off at midnight. Perhaps it will run the job next time it is turned on, but I doubt it. Apparently,
anacron can do this but I have never used it. Another solution would be to have your job create a file every time it is run and then write a script that checks the modification date of the file and runs the job again if it is more than a day old. For example:
## The command you want to run, change this to whatever
## command you actually want.
## Define the log file
## If the log file doesn't exist, run your command
if [ ! -f $LOGFILE ]; then
## If the command succeeds, update the log file
$COMMAND && touch $LOGFILE
## If the file does exist, check its age
AGE=$(stat -c "%Y" $LOGFILE);
## Get the current time
## If the file is more than 24h old, run the command again
if [[ $((DATE - AGE)) -gt 86400 ]]; then
$COMMAND && touch $LOGFILE;
If you then make a crontab that runs the script every hour (
@hourly), it will run your command every time 24 hours have passed since the last time it ran.