The origin of the name cron is from the Greek word for time, χρόνος

For reference, here’s how to create a quick cron job task that can run on a recurring schedule on Linux. You have one of two options to get a script to run, either dropping a script into one of the following folders on a linux machine or creating a line entry in a crontab -e file.

Easy – Drop a script into one of the following folders:

  • /etc/cron.hourly
  • /etc/cron.daily
  • /etc/cron.weekly
  • /etc/cron.monthly

Harder – add a path/script to execute to the crontab -e file with the unique cron timing prefix. Start by opening the cron timings file by running the following at a terminal.

crontab -e

Then you can add a line at the end of the comments with the following format:

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │                                       7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  /path/path/command_to_execute

So for example if you wanted to run a script that runs every hour on the hour,

0 */1 * * * /path/to/run.sh

Or if you wanted it to run every minute, or 5 or 15 minutes,

*/1 * * * * /path/to/run.sh

*/5 * * * * /path/to/run.sh

*/15 * * * * /path/to/run.sh

Or if you wanted it to run every night at midnight,

0 0 */1 * * /path/to/run.sh

I think you get the point. The spec for changing the run schedule for a cron job is unique, here’s a website that can help turn your *****’s into something you can quickly make sense of.

https://crontab.guru/#*/1_*_*_*_*

Photo by Emma Matthews on Unsplash

David

Author David

More posts by David

Join the discussion One Comment

Leave a Reply to Docker Local Image Repository Bloat – Prune Daily – David Manske on innovation, entrepreneurism, engineering, tips, tricks and ramblings Cancel Reply