• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

How to run cron every hour

Thumbnail for Philip WilkinsonThumbnail for Philip WilkinsonThumbnail for Philip WilkinsonThumbnail for Philip Wilkinson
Philip Wilkinson

Philip Wilkinson

Software Engineer, Amazon

Published: 2/1/2024

About Terminus

Scheduling cron jobs every hour

Use the following expression: 0 * * * * <command to schedule>

 # Example using cron to run a monitoring script every hour
 0 * * * * /scripts/monitor.sh

Run in Warp

Other variations and examples include:

Every half an hour: */30 * * * *

At specific minutes:

  • Every hour on the hour - 0 * * * *
  • Every hour at 30 - 30 * * * *
  • Every hour at 15 - 15 * * * *
  • Every hour at 5 - 5 * * * *

On different hour-like cadences:

  • Every other hour - 0 */2 * * *
  • Every odd hour - 0 1-23/2 * * *
  • Every hour except 3am - 0 0-2, 4-23 * * *

Within a range of hours:

  • Every hour between 9-5 - 0 9-5 * * *
  • Every hour starting from 3am - 0 3-23 * * *

Rules of Cron Expression Syntax

These examples are indicative of several rules of cron expression syntax:

  • A field containing an asterisk (*) means that it will be run from the first to the last of that field
  • Ranges of times are indicated by two numbers separated by a hyphen (-) and this range is inclusive
  • Following a range with /No. specifies the skips of the numbers value through that range
  • A list, with numbers separated by commas , specifies an execution on those intervals

Each of these expressions then take on the following structure:

 | -  - - -  - - Minute (0-59)
 | |  - - -  - - Hour (0-23)
 | |  | -  - - - Day of the month (1-31)
 | |  | |  - - - Month (1-12)
 | |  | |  | - - Day of the Week (1-7, Monday to Sunday)
 * * * * * 

Run in Warp

Where each field represents a period of time. In this case, the syntax 0 * * * * will schedule the cron job for every hour of every day of every month on the hour. This is because numbers indicate the specific time, in this case minute 0, and the asterisk tells the computer to run the job from the first to the last of that field, so every hour of every day of every month.

Which means that with these rules you should then be able to schedule a cron job for any period you want.

What Exactly is a Cron Job?

The cron command line utility is a job scheduler used to schedule regular actions on your computer. Jobs that are scheduled are known as cron jobs and are run periodically at fixed times, dates or intervals. This is often used for things such as scheduling system maintenance, checking broken links or downloading updated files.

For these instructions to run, they should be placed in a cron file which contains commands to be run at the specific times. The default system for this is the cron table or crontab configuration which can be found in /etc/crontab on your computer. Your operating system will then be able to recognise that it needs to perform those actions on the given schedule.

Cron Job Limitations

The shortest time interval possible between jobs is 60 seconds. This means that cron is not suitable when you want to schedule something with more granularity.

Commands to execute specified in a crontab file can only be run on the same computer where the file lives.

There are no auto retry mechanisms if a job fails. This makes cron jobs unsuitable for incremental tasks where one task depends on another. The action will only run at the specified time.

If your use case doesn’t fall under these limitations - cron should work well for you!

Written by

Thumbnail for Philip WilkinsonThumbnail for Philip WilkinsonThumbnail for Philip WilkinsonThumbnail for Philip Wilkinson
Philip Wilkinson

Philip Wilkinson

Software Engineer, Amazon

Filed Under

Related Articles

List Open Ports in Linux

Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.

UnixLinux
Thumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan Ludosanu
Razvan Ludosanu

Count Files in Linux

Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.

LinuxUnix
Thumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan Ludosanu
Razvan Ludosanu

How to Check the Size of Folders in Linux

Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.

LinuxUnix
Thumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan Ludosanu
Razvan Ludosanu

Linux Chmod Command

Understand how to use chmod to change the permissions of files and directories. See examples with various chmod options.

Linux
Thumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan LudosanuThumbnail for Razvan Ludosanu
Razvan Ludosanu

POST JSON Data With Curl

How to send valid HTTP POST requests with JSON data payloads using the curl command and how to avoid common syntax pitfalls. Also, how to solve the HTTP 405 error code.

BashUnixLinux
Thumbnail for Neeran GulThumbnail for Neeran GulThumbnail for Neeran GulThumbnail for Neeran Gul
Neeran Gul

Format Command Output In Linux

Learn how to filter and format the content of files and the output of commands in Linux using the awk command.

Linux

Create Groups In Linux

Learn how to manually and automatically create and list groups in Linux.

Linux

Switch Users In Linux

Learn how to switch between users, log in as another user, and execute commands as another user in Linux.

Linux

Remover Users in Linux

Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.

Linux

Delete Files In Linux

Learn how to selectively delete files in Linux based on patterns and properties using the rm command.

Linux

Find Files In Linux

Learn how to find and filter files in Linux by owner, size, date, type and content using the find command.

Linux

Copy Files In Linux

Learn how to safely and recursively copy one or more files locally and remotely in Linux using the cp and scp command.

Linux

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Request demo
Thumbnail for nullThumbnail for nullThumbnail for nullThumbnail for null