How can We Create Cron Jobs and Add them in Cpanl.

Author: Zeeshan Rasool  |  Last updated on PHP Tutorials, Web Development

Creating cron jobs and implementing them on server is little bit tricky for web beginners. Here i will elaborate a simple example for creating and implementing crons on PHP server.

Here is a simple code which deletes all records whose type is “Graphics”.
Cron job is an independent file which is executed by server on our given time. We need db info so that we can connect to db and performs our operations on data.

In above code we are creating db login information variables. Now we will try to connect to db in next step.

After successful db connection we will perform our required operations. In this example we will delete some records.

Now our sampled cron has been ready and next step is to put this file on server. Log in to your hosting panel using your login info and go to cpanel which is main page as shown below. Click on cron job icon.

On next page you will see a window which has some options about your cron running time and path to cron file. In this case i put my file on root so i will give my path like this :

Here onw thing in above syntax, php -f is a syntax which is required and executes an action. While home/my-folder-name/ is my root path. Now next i will give my file name if it is on root. Other wise give your own path according to your folders.
Next yo u have to set up cron job running times and date.
After mints, hours or daily, weekly.
Give a single mint interval to check that cron is working fine. Confirmation will be get by receiving an email if you have given your correct email on that hosting.

Recommended WordPress Themes Store

If you enjoyed this post, please consider leaving a comment below or subscribing to the RSS feed to have future articles delivered to your feed reader. You can also follow us on Facebook or Twitter @99Points

This awesome post has been created by 99Points editor's team. You can follow our updates on Twitter and facebook, OR drop an email at

Comments are closed.

Email Subscriber!

Be the first to know about new updates



Popular post