Quick Tip: Running a PHP script at intervals (Scheduled Task) using Cron Jobs on cPanel

There are times you might want to perform a particular task several times on your website e.g, sending an email to your users on their birthday, deleting old records from your database every month etc. With Cron, you can get it done easily.

Here I will try to show you how quickly you can get that done on cPanel if you already have the PHP script you want to run at intervals.

Even if you do not know anything about cron jobs and have never run a cron job before, you can get started with the simple cron tool built into cPanel. To get to Cron Jobs on cPanel, enter the url below on your browser; remember to change “mysite.com” to your website url.


To run a job, you’ll need the path to the PHP script you want to execute. I always advise you put all Cron scripts in a folder and use .htaccess to protect the files there.

The command to run:
wget -O - -q -t 1 http://www.mysite.com/cron/scriptname.php where “/con/scriptname.php” is the path to your PHP script or /home/mysite/public_html/cron.php

Next you’ll want to select an option from all the select boxes. Remember to select an option in each box. If you want something to run every day at 4AM, select Minute: 0; Hour: 4; Day: Every; Month: Every; Weekday: Every;

Click save and that’s all. You’ll get an email every time the cron job runs, but if you don’t want to get an email, put a blank space into the output email field at the top.

I write codes... web, mobile, desktop and hack stuffs

Leave a Reply

Your email address will not be published. Required fields are marked *