Follow
Ubuntu Linux

How to Run Cron Jobs every Minute, Hour, Day on Ubuntu Linux

Richard
Written by
Richard
Jul 30, 2022 Updated Mar 19, 2026 3 min read
Enable Automatic Suspension in Ubuntu Linux Easily
Enable Automatic Suspension in Ubuntu Linux Easily

You can run cron jobs every minute, hour, or day on Ubuntu Linux by editing the crontab file.

A cron job is a scheduled task that runs automatically on Unix-like operating systems, commonly used for automating repetitive operations like log cleaning or system backups.

Understanding crontab syntax allows you to precisely control execution intervals. For instance, to run a script every minute, you would use the entry `* * * * * /path/to/your/script.sh`.

This guide shows you how to configure these schedules efficiently for your Ubuntu system.

⚡ Quick Answer

Edit your crontab file by running `crontab -e`. Use asterisks for minute, hour, or day intervals, like `* * * * *` for every minute.

How to schedule cron tasks in Ubuntu Linux

As mentioned above, cron jobs in Linux are commonly used for operational and mundane functions such as cleaning up logs, backing up system files, and others.

Below is how one can use cron jobs to perform tasks at intervals.

Crontab (cron table) is a text file that contains the schedule of cron entries to be run at specified times. Each line in the user crontab file contains six fields separated by a space followed by the system command to run.

An example of a cron file will look similar to the one below:

💻Code
* * * * * system command(s) to run
| | | | |
| | | | |     schedules
| | | | |     -------
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12) (January - December)
| | --------- Day of month (1 - 31) (1st day to 31st)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

The asterisk ( * )or star operator tells the cron to run or execute constantly. For example, the task will run every minute if an asterisk is in the Minute field.

Same for an hour, Day, Day of the week, month, Day of the month, and so forth.

An ( ) hyphen operator allows you to specify a range of values. For example, you can specify days of the week as ( 1 – 5 ), representing (Monday to Friday) when defined in the Day of Week field.

A (, ) comma operator allows you to define a list of repeated values. For example, if you defined (1, 2, 3) in the Hour field, it represents (1 am, 2 am, 3 am). If no day is defined, the task will run daily at 1 am, 2 am, and 3 am.

It can also be represented as (1, 2, 5-8), representing (1 am, 2 am, and 5 am to 8 am).

The syntax of the system-wide crontab file contains an additional mandatory user field that specifies which user will run the cron job.

💻Code
* * * * * <username> command(s) to run

There are still more to cron and scheduling jobs, but the above should get you started.

How to schedule a cron job to run every 5 minutes

If you want the cron job to run every 5 minutes, enter the line below in the crontab file.

💻Code
0,5,10,15,20,25,30,35,40,45,50,55  * * * * ~/script.sh

How to schedule a cron job to run every 10 minutes

To run a job every 10 minutes, enter the line below in the crontab file:

💻Code
*/10  * * * * ~/scripts.sh

How to run a cron job every 10 minutes

To schedule a cron job to run every 15 minutes, enter the line below in the crontab file:

💻Code
*/15  * * * * ~/script.sh

How to run a cron job every minute

To run a cron job every minute, enter the line below in the crontab file.

💻Code
* * * * * ~/script.sh

An example cron entry for Let’s Encrypt certbot to renew certificates automatically looks like the one below:

🟨JavaScript
# the cronjob.timer function takes precedence over this cronjob.  For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a ! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

That should do it!

Conclusion:

  • Cron jobs in Ubuntu Linux are useful for automating operational and mundane tasks.
  • The key to scheduling tasks with cron jobs lies in understanding the syntax and utilizing the crontab file effectively.
  • By leveraging the asterisk, hyphen, and comma operators, users can create precise schedules for their cron jobs.
  • Examples of scheduling cron jobs at various intervals, along with a Let’s Encrypt certbot renewal cron entry, demonstrate the versatility of this feature.
  • With this understanding, users can efficiently manage and automate tasks using cron jobs in Ubuntu Linux.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Mount Windows 11 Shares on Ubuntu Linux
Ubuntu Linux How to Mount Windows 11 Shares on Ubuntu Linux
How to Change Default Distro in Windows Subsystem for Linux
Windows How to Change Default Distro in Windows Subsystem for Linux
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

0 Comments

Leave a Comment

Your email address will not be published. Required fields are marked *