A cron job is a Linux command used for scheduling tasks to be executed sometime in the future. This is normally used to schedule a job that is executed periodically – for example, to send out a notice every morning. Some scripts, such as Drupal and WHMCS may require you to set up cron jobs to perform certain functions.
For most cron jobs, there are three components present:
- The script that is to be called or executed.
- The command that executes the script on a reoccurring basis. This is typically set in cPanel.
- The action or output of the script, which depends on what the script being called does. Frequently, scripts called as cron jobs modify files or databases. However, they can perform other tasks that do not modify data on the server as well, such as sending out email notifications.
Most scripts that require the use of a cron job will give you specific instructions on what needs to be setup, frequently giving examples.
Using cPanel to Set a Cron Job
To add a cron job in cPanel, follow these steps:
- First, you’ll need to log in to cPanel
- From the dashboard, either search for Cron Job or navigate to the Advanced menu and click on the icon for Cron Jobs
- Next, you’ll need to select an email where you’d like to receive cron output. If the email address listed beside Current Email is valid, simply leave it. If you’d like to use a different email address, enter it into the form field next to Email and click Update Email once you’ve finished
- In the section labelled Add New Cron Job, you can specify what command you’d like to run as well as its frequency. Start by entering your desired command in the bottom form field labelled Command. You can list any Linux command here or, if you have a file you’d like to run at a certain time, simply provide the path to the file you’d like to run
- Next, move back up to the form field labelled Common Settings and select which frequency you’d like the command to run at from the available options listed in the dropdown menu. This will automatically update the other time settings according to your choice
- Alternatively, you can choose to enter your recurring frequency manually by adjusting the individual time settings. Minute, Hour, Day, Month, and Weekday can all be modified to achieve your intended results
- When you’ve finished making your selections, simply click the Add New Cron Job button to finalize the process
And now you’ve successfully scheduled a command using the Cron Jobs tool within cPanel. If you have other commands that need to be set, simply repeat this process for any other commands.
Not a cPanel user? No problem! Read on to learn how to schedule cron jobs using the Plesk control panel as well.
Using Plesk to Set a Cron Job
to add a cron job using Plesk, just follow these steps:
- First, log in to your Plesk control panel
- Once you’re logged in, on the left side of the dashboard under Server Management, click the option for Tools & Settings
- Now, on the right side panel, under Tools & Resources, click on Scheduled Tasks
- On the next screen, click on Plesk Administrator User
- On the Scheduled Tasks screen, under Tools, click on Add New Task
- On the following screen, provide all requested information as shown in the image below
- Now, scroll down a bit and in the section beneath Task priority, you’ll see a calendar. Here, you can select the frequency with which your command runs. For this example, we’ve selected Every day, Every month, and under Days of the week we’ve also selected Every day
- If you want to schedule a different frequency with which your command will run, simply select the corresponding check boxes. For instance, if you wanted a scheduled task to run every minute of every hour, or every day, you’re calendar would look like this:
- Once you’ve finished scheduling your task per your requirements, simply click OK to finalize your selections
And now you’ve successfully schedule a cron job using the scheduled tasks tool within Plesk.
Now that you know how to schedule tasks using both cPanel and Plesk, you should be ready to start scheduling cron jobs as needed. Just remember, if you encounter any problems, feel free to issue a support ticket and our support team will be happy to help.
- DNS Configuration: Everything You Need to Know
- What is the DNS Trailing Period?
- How to Resolve Error 421 Service Not Available and Other Issues with FTP Service
Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.
The Hivelocity Difference
With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.