How to Run and Configure Cron Jobs on hPanel

Performing the same task on your site over and over again can not only become tiring, but time-consuming as well. That’s why in this tutorial, we’ll walk you through how to set up a cron job on the hPanel.

Cron jobs let us program our system to execute simple repetitive tasks on a schedule automatically. However, though simple to use, configuring a cron job for the first time might appear somewhat confusing.

Set Up Your Cron Job

In this tutorial, we’ll cover the three main requirements for managing cron jobs: navigating the hPanel, creating a cron job, and deleting one.

Login to the hPanel

Open your hPanel. Go to the Hosting column where you will find a list of all of your hosting accounts. Click the Manage button of the hosting account you want to set-up a cron job on.

Configure Your Cron Jobs

Scroll down the page until you find the Advanced column. Click on the Cron Jobs button. A new window will appear.

Cron Job section location on the hPanel

Let’s breakdown what you need to fill in to create a cron job.

There are two options available in the TYPE section – PHP and Custom.

Cron Job type selection area

Selecting PHP will allow you to run .php files only, while Custom gives you the ability to execute scripts with different extensions and commands.

Second is the COMMAND TO RUN section. Here, you will write the command you want to execute.

Cron Job command area

The rest of the menus are as follows:

  • COMMON OPTIONS. Here you can choose one of the pre-made interval settings for your command.
  • MINUTE, HOUR, DAY, MONTH, and WEEKDAY. Here you can adjust the exact minute, hour, day, month, and weekday of the task.

After you are done configuring the settings, click the Save button. If the command can successfully trace the .php file, you should see the following notification.

Successfully created cron job popup

However, issues may occur. If that happens, there will be a pop-up message telling you where the mistake(s) has occurred.

Since a cron job will run the command automatically, you must set the timing carefully to prevent your site from overloading.

How to Delete Cron Jobs

To delete a cron job, go to the same page where you created your cron job. Scroll down to the bottom. There you should see the List of Current Cron Jobs. Here, the Delete button is right below the Actions column.

A list of existing cron jobs on the hPanel

Cron Job Examples

Now that you know how to set up a cron job, we can try to put the theory to practice. Here are two simple examples where a cron job can automate a routine command.

Use a Cron Job to Clear Website Cache

Let’s create a cronjob that will clear your site’s cache.

Because the script will use a .php file, select the PHP option under the TYPE section. Next, we select the file – clear-cache.php that is located in the public_html directory. Thus, the command will be public_html/clear-cache.php.

It’s important to point out that you can also add a .php script when using the Custom option. However, the command is much simpler to set up with the PHP option.

An example of a php cron job

Moving forward, let’s say we want to have the script run at midnight every single day. Under the COMMON OPTIONS, we select the Once a Day option, with 0 selected in the HOUR and MINUTE sections as shown in the screenshot above.

Save the changes and you’re done, your cron job is ready to run.

Use a Cron Job to Create Automated Website Backups

Second, let’s make a cron job that will create a regular backup of your website. Since we will use a file with a .sh extension, we will select the Custom option under the TYPE section. The backup is scheduled to run on the 15th day of every month, at 9 p.m. The options will look like this:

Example of a custom cron job

Just click Save and your cron job will be ready to run.

Additional Resources

Cron jobs are handy tools that every site owner should consider learning and using. It will let the system handle repetitive tasks so that content creators can focus on other aspects of their project. And now you know how to set up a cron job.

Configuring the settings for a cron job is easier than it looks. You only need to access the hPanel and set up the time when a certain cron job should execute a script.

Now, if you want to learn more about how to set up cron jobs, here are some additional articles you should definitely check out:

The author

Edward S.

Edward is an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward's goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.