Run a PHP file in a cron job using CPanel
In crontab system :
/usr/bin/php
is php binary path (different in some systems ex: freebsd/usr/local/bin/php
, linux:/usr/bin/php
)/home/username/public_html/cron/cron.php
should be your php script path/dev/null
should be cron output , ex:/home/username/stdoutx.txt
So you can monitor your cron by viewing cron output /home/username/stdoutx.txt
Setting up a Cron Job on CPanel to executes a PHP script
Since your script resides in your public_html
directory you can use wget
for your Cron Job
wget -O - -q https://yoursite.com/wallboard/update.php
-O -
output is written to the standard output in this case it will go to the email address you specify in CPanel
-q
quiet mode
Running PHP script from cPanel Cronjob
I found a solution by using wget
wget -q https://example.com/parteneri-xml.php
Run cron job on cpanel with php7 version
Command to run a PHP 7.0 cron job:
/opt/cpanel/ea-php70/root/usr/bin/php /home/username/public_html/myjob.php >> /home/username/myjob.log
Command to run a PHP 7.1 cron job:
/opt/cpanel/ea-php71/root/usr/bin/php /home/username/public_html/myjob.php >> /home/username/myjob.log
Command to run a PHP 7.2 cron job:
/opt/cpanel/ea-php72/root/usr/bin/php /home/username/public_html/myjob.php >> /home/username/myjob.log
Run a php file in a cron job using whm cpanel
Supposing you want to run your cronjob every 15 minutes, your cron job syntax should be something like this:
*/15 * * * * /usr/local/bin/php -f /home/username/public_html/admin/cron.php
That means the cron will run every 15 minutes.
Related Topics
What Type of Hash Does Wordpress Use
Is There a PHP Library For Email Address Validation
Does Sleep Time Count For Execution Time Limit
Is PHP Compiled or Interpreted
Find Highest Value in Multidimensional Array
Best Way to Manage Long-running PHP Script
PHP String Concatenation, Performance
PHP Equivalent of .Net/Java'S Tostring()
How to Rely on PHP PHP.Ini Precision Workaround For Floating Point Issue
How to Remove the Querystring and Get Only the Url
How to Properly Use a Pdo Object For a Parameterized Select Query
Why Won't My PHP App Send a 404 Error