How to Create a Cron Job for Scheduled Task on Your Site

How to Create a Cron Job for Scheduled Task on Your Site

Many webmasters are looking for the methods to create a Cron Job to carry out certain commands on their servers and do tasks repeatedly and automatically, because they know that creating a Cron Job enables them to run websites stably and smoothly, save disk space, and run some certain functions when they are running a site built with Drupal.

However, it is not easy for many most webmasters to set up a Cron Job, especially for the newbies who have little hosting knowledge or few technical skills. Therefore, we worked out this easy-to-understand tutorial, aiming to teach you how to create a Cron Job using cPanel control panel and Plesk control panel easily.

Note that only those people who use hosting packages with SSH and Cron Jobs have the ability to create, edit or delete Cron Jobs, so if you are using a package without either of the 2 items, you should change your web host and purchase a new package from web hosts offering both of the 2 must-to-have programs, such as BlueHost, InMotion and JustHost. Now, move on to learn the details.

Create a Cron Job in cPanel

cPanel is the most popular and user-friendly control panel in the industry, adopted by a numerous reputed web hosts. Using this control panel, you are able to manage every aspect your account and site easily. Besides, you are able to create new email account in it with the least effort being made. Now, learn how to set up a Cron Job in the following parts.

Step 1. Log into your cPanel control panel and scroll down to the “Advanced” part. Now, you are able to see many options within this part, click the “Cron jobs” icon.

Create a Cron Job in cPanel Step 1

Step 2. After clicking “Cron jobs” icon, you are capable of seeing a new screen with some information about this item, a warning and 2 buttons – Standard and Advanced. Then, you need to choose your experience level. Here, we suggest you to choose “Standard”.

Create a Cron Job in cPanel Step 2

Step 3. A new page appears after you chose your experience level. At the top of this new page, you need to enter your email address where the output of the Cron Job or any errors resulting in attempting to execute the job will be sent to. In addition, each time a Cron job runs, an email will be sent to this email address. Therefore, you need to ensure the address you enter is available.

Create a Cron Job in cPanel Step 3

After entering your email address, type the command followed by any parameters in the blank rectangle below “Entry 1”. Now, choose when and how often the Cron Job should run by selecting numbers in the following 5 menus. Here, we suggest you to set it run with an interval over 15 minutes like HostGator, ensuring there are no unnecessary loads caused by the Cron Job you created.

Create a Cron Job in cPanel Step 4

Step 4. After setting when and how often you want the Cron Job to run, click “Save Crontab” to finish the creation of a new Cron Job.

Create a Cron Job in Plesk

Plesk is a famous control panel, used by many hosting companies. Although this control panel is not as popular as cPanel, it also helps webmasters manage sites and accounts effortlessly. In addition, it is very simple to set a Cron Job within Plesk. Now, see the steps of setting a Cron Job within Plesk in below.

Step 1. Log into Plesk control panel. Then, scroll down to “Additional Tools” section, click “Scheduled Tasks” icon.

Create a Cron Job in Plesk Step 1

Step 2. After clicking “Scheduled Tasks” icon, you can see a new page, select the system user under who the command should be run. Then, click “Next”.

Create a Cron Job in Plesk Step 2

Step 3. At the new screen, you are able to see 2 tools, and then clicking “Preferences” icon. Under “Preferences”, enter the email address behind “Send Crontab messages to e-mail address” and click “OK” button when finished.

Create a Cron Job in Plesk Step 3

Step 4. After entering your email address, you are redirected to the screen with 2 tools. At this time, you need to click “Schedule New Task” to go to another page. At the new page, the task is already switched on by default. Next step is to fill parameters in “Minutes”, “Hours”, “Day of the Month”, “Month” and “Day of the Week” to set when and how often you want the Cron Job to run. Now, enter the command behind “Command” and you need to make sure the command you write down is 100% correct.

After entering the command, click “OK” button to save the changes.

Create a Cron Job in Plesk Step 4

Best Web Hosting Providers Offering Cron Jobs

If you try to create a Cron Job, you have to choose a hosting package integrated with this item. In these years, we have reviewed 100+ hosting companies offering Cron Jobs, among which InMotion, BlueHost and HostMonster are the best web hosting choices. Now, learn more highlights of the 3 companies in the following table.