Home    Articles


How to set up cron jobs in wordpress using cPanel


I will not tell you in this article what is a cron job but i can give you an ideea in few words:
- is a request on your server, like any other request that a user does.

In order to set up a cron job in wordpress you need to add a function in one of your plugins.
This function will be hooked to ‘plugins_loaded’ action.
When all plugins are loaded our funtion will be called and our code will run.

The code:

add_action( 'plugins_loaded', 'our_function' ); 
function our_function()
    //we will check for a link variable
    if(isset($_GET['run_cron']) && $_GET['run_cron']=='our_function')
       //here will be the code

Now that we have the code for our wordpress cron job, let’s add the cron job in cPanel.
This step is very important.


1)Select from the “Common Settings” how often this function to run, or you can configure the cron exactly how you want.

2)The final step is to set the command.
The command will look like this: wget http://your-website.com/wp-cron.php?run_cron=our_function

This command will request your server and your function will be called.
By calling your function you need to have the run_cron variable in the link with the proper value.

3) Click “Add New Cron Job”.

That’s all.