Close this search box.

How to run a cron job for every hour?

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

There are some tasks that we need to run after some time like we have to schedule these tasks. So for the tasks like this Linux offer a thing that is called cron job. Cron job helps you to perform those task that needs scheduling. so here in this article, we will check how to run a cron job for every hour.

What is a cron job?

Cron is a time-based job scheduling utility in Unix-like operating systems. It allows users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. These jobs are called “cron jobs.”

Cron is commonly used to automate maintenance or administration tasks, such as running backups or sending emails. It is also used to schedule recurring tasks, such as running a script to check for updates every hour.

Cron uses a configuration file called the crontab, which specifies the schedule for each job. The crontab is edited using the crontab command. Each user on a system can have their own crontab file, and the system administrator can also set up a global crontab file for jobs that need to run on the entire system.

Cron jobs are typically executed in the background, and the output (if any) is usually sent to the user via email or saved to a log file. Cron is a powerful tool that allows users to automate many tasks, but it can be difficult to use and troubleshoot.

Why do we need cron jobs?

Cron jobs are useful for scheduling tasks to run automatically in the background at a specific time or date. This can be useful for a variety of reasons, including:

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

  • Automating repetitive tasks: Cron can be used to automate tasks that are performed on a regular basis, such as running backups or sending emails. This allows you to set up the task once and have it run automatically at the specified time, without the need for manual intervention.
  • Running tasks on a schedule: Cron can be used to schedule tasks to run at specific times, such as every hour or every day. This is useful for tasks that need to be run on a regular schedule, such as checking for updates or cleaning up temporary files.
  • Keeping systems up-to-date: Cron can be used to schedule tasks that ensure that your system is up-to-date, such as running security updates or installing new software. This can help to keep your system secure and ensure that it is always running the latest versions of programs and libraries.
  • Improving performance: Cron can be used to schedule tasks to run at times when the system is idle, such as during the night or on weekends. This can help to improve the performance of the system by avoiding running resource-intensive tasks during peak usage times.

Overall, cron is a useful tool for automating tasks and scheduling jobs to run automatically on a regular basis. This can save time and effort, and help to keep your systems running smoothly and efficiently.

Create Cron Job in Linux

To create a cron job in Linux, you will need to use the crontab command. This command allows you to edit your crontab file, which is the configuration file that specifies the schedule for your cron jobs.

To create a new cron job, follow these steps:

  • Open a terminal window.
  • Use the crontab -e command to open your crontab file in a text editor. This will create a new crontab file if one does not already exist.
  • Add a new entry to your crontab file that specifies the schedule and command for your cron job. The crontab file uses a specific format to specify the schedule for each job.
minute hour day-of-month month day-of-week command

For example, the following entry will run the my-command command at minute 0 of every hour:

0 * * * * my-command
  • Save and close the crontab file.
  • Use the crontab -l command to list your cron jobs and verify that your new job has been added.

Note that the exact syntax and options for the crontab command may vary depending on your system and the version of cron that you are using. For more detailed information, you can consult the crontab man page by running the man crontab command.

How to set a cron job for every hour?

To run a cron job for every hour, you can use the following crontab entry:

0 * * * * command
How to run a cron job for every hour?

This crontab entry specifies that the command should be run at minute 0 of every hour.

To edit your crontab file, you can use the crontab -e command. This will open your crontab file in a text editor, where you can add the entry above.

For more detailed instructions on using cron, you can refer to the crontab man page by running the man crontab command. This will provide detailed information about the crontab file format and the options available for scheduling jobs.

It’s important to note that the exact syntax for your crontab entries may vary depending on your system and the version of cron that you are using. If you have any questions or need help with specific cron syntax, you can consult the cron documentation for your system or ask for help on a forum or online community dedicated to Linux or system administration.

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

We also have an article about How To Find Cron Jobs In Linux.

How to set and find Cron Jobs using the CyberPanel dashboard?

Login to your CyberPanel in your access link using your login credentials.

Go to CyberPanel dashboard

Click on WordPress -> List WordPress from the left-hand side menu

This is your List WordPress Website page. Click on your website

This is your site’s WordPress Manager. Click on Manage Application

Scroll down and click on Cron Jobs

Now click on Fetch Current Cron Jobs to view your cron jobs for your site.

To add a cron job using CyberPanel Dashboard

Following the above-mentioned steps to go into the Cron manager, and click on ADD CRON

Add all the relevant data (minutes, Hours, Day, Month, and Day of the week) according to your cron job and enter your command. Click on Add Cron

We also have a detailed video article on cron hob check here.

Related Articles:

How to Secure Server

Editorial Team

The CyberPanel editorial team, under the guidance of Usman Nasir, is composed of seasoned WordPress specialists boasting a decade of expertise in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Since its establishment in 2017, CyberPanel has emerged as the leading free WordPress resource hub in the industry, earning acclaim as the go-to "Wikipedia for WordPress."
Unlock Benefits

Become a Community Member

Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!