Create Cron job to run PHP Script in Cpanel

Hi All,

Today i just want to share that how to create  a cron job in Cpanel to run the PHP script.

I hope everyone knows that what is Cron job : it is the task schedule in Linux which will run on predefined time interval. its same concept like schedule tasks in Windows OS.

To create the cron job, open the Cpanel and select “cron jobs”.

Select Cron job in Cpanel

You can see that in drop down list there are lots of common schedules of crone job, you can select it, or create your own schedules.

Common settings in Cpanel

In Command text box, write the PHP program path and file to be executed like:

/usr/local/bin/php -q /home/<username>/script.php


to find the path to php,
log on to the server with SSH, then run this command:
“”””””””””””-
which php
or
whereis php
“”””””””””””””-
This will give you the path to the php executable, probably:
/usr/local/bin/php

Posted

in

by

Tags:


Related Posts

Comments

One response to “Create Cron job to run PHP Script in Cpanel”

  1. Chris Avatar
    Chris

    Hi,

    very helpful information guide.

    /usr/local/bin/php -q /home//script.php

    What’s with the “-q” ????

    The problem I noted from my own (beginner) experience is that using different variations of the PHP program path, it always showed the “tick” sign indicating it’s correct:

    /usr/local/bin/php /home//script.php

    /usr/local/bin/php -q /home//www/script.php

    /usr/local/bin/php -q /home//public_html/
    script.php

    /usr/local/bin/php /home//www/script.php

    /usr/local/bin/php /home//public_html/
    script.php

    /usr/local/bin/php/home//script.php

    So, which one is the official correct one that would definitely work?

    Also, I was told that some PHP actions or functions must be “enabled” such as url_include and url_fopen – for certain php script to work.

    Please let me know your answers/guidance to the above.

    Thank you in advance

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading