How do I set up a WordPress cron job?

In this knowledge base article, we explain how you can manually set up a WordPress cron job. Because with our WordPress hosting you simply have the option to add a cron job. The advantage of manually adding cron jobs is that you have an overview of how many resources your site uses instead of automatic cron jobs which are less clear.

Advantages of a WordPress cron job

Normally, if you haven't set up any cron jobs yet, the website's resources are only called the moment the visitor clicks on the site. Think of it as a dinner you organize for your friends or family. You know the diner (the visitor) is coming so you can do two things: you only start cooking when the doorbell rings, or you make sure the food is already prepared so the guests (the visitor) can sit down smoothly right away.

Through good preparation, the visitor of your website will also have a better experience from his or her visit to your site.

Step 1: Adjust wp-config.php

To manually add cron jobs, you will first need to adjust the wp-config.php file. Log into DirectAdmin, then choose System Info & Files in the left bar and then File Manager.

system info & files

From the File Manager, click on domains, then click on your domain and finally on the public_html folder. Public_html is the folder where the wp-config.php file is located.

search public_html

Step 2

Find the following line in the wp-config.php file:

/* That's all, stop editing! Happy publishing. */

Add the following text above it:

define( 'DISABLE_WP_CRON', true ); 

Save the file afterwards. 

Step 3

Go back to DirectAdmin and go to Advanced and then Cron Jobs.

set up cron job

Step 4

Next, click on Create Cron Job, you will then enter the following screen:

create cron job

In this screen, you can enter the details for when you want to execute the cron job. At the * you can enter a number, for minute this is 0-59 and for hour 0-23 and so on. A good starting point is to set the cron job to every 10 minutes. You do this by entering */10 for the minute.

For the command, enter the following text:

/usr/local/bin/php /home/jegebruikersnaam/domains/jedomein.nl/public_html/wp-cron.php

Don't forget to enter your own username here for jegebruikersnaam, the same applies for changing jedomein.nl to your own domain. 

The username can be found in DirectAdmin, see also the image below. Note that the username is always in lowercase letters. 

find DirectAdmin username

Next, click on create to save your cron job.

 

If you can't figure it out, you can always contact our support department.


Still have questions? Get in touch.