How to create a Scheduled Task from the Command Line in Fedora

- by

I don’t do this every day, especially not on Fedora, so here’s a quick refresher on how to setup a Cron Job or Scheduled Task from the command line. While other tools will work (like anacron), crontab is going to do a fine job for something you want to execute repeatedly. In my case a daily backup script.

To invoke, we can type crontab -e and a Nano window will open by default. That’s the other reason why I’m taking this note: I usually don’t use nano (I’m a vi guy). The window may display existing cron jobs in the following format:

0 12 * * * /path/to/script

We have five numbers/asterisks at the beginning of each line, separated by spaces, followed by the full path to something that will be executed. You can specify which user said script should be executed as I believe, but I’ve never used this feature. Arguments can be passed after the script. The numbers mean the following:

  • minute (0-59)
  • hour (0-23 military style)
  • day of the month (1-31)
  • month (1-12)
  • day of the week (0-7, where both 0 and 7 mean Sunday)

An asterisk means “any” or rather “every hour/day/month”. Hence, the above line would execute my script at 12:00 every day of every month.

Other combinations can be used, like a range of days (1-5 for Monday to Friday), for a full rundown of options check out Vivek’s comprehensive guide here.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site witout any pesky ads! More details here.

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.