Viewed   208 times

I am just trying to run a PHP script using a cron job within CPanel - is this the correct syntax:

/usr/bin/php -q /home/username/public_html/cron/cron.php >/dev/null

I am not getting any email notifications stating a cron has been completed, do I need to do anything specific with the PHP file?

 Answers

2

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

Wednesday, August 3, 2022
5

Looks like that you copied your full php.ini from your windows machine (probably the dev environment) up to a remote server which is running some linux distribution.

The extensions listed in your xampp provided php.ini won't work this way over there. If you are certain that you want to copy the whole php.ini from your dev machine, (you most likely won't need that) you will probably have to remove or edit the extension= lines to fit the environment (They most likely should end with .so at least and have a different path). Checking every path related setting would be wise too.

(Using full paths in every extension= line is foolish since there's extension_dir)

Wednesday, November 9, 2022
 
xxx
 
xxx
4

Your cron should change the working directory before running PHP:

cd /var/www/vhosts/domain.com/httpdocs/app/protected/classes/cron/ && /usr/bin/php -q runner.php

Note that if the directory does not exist, PHP will not run runner.php.

Sunday, December 18, 2022
 
sundar
 
5

Crontab needs the full path on your server.

0 0 * * * php /var/www/vhosts/domain.com/httpdocs/scripts/example.php

This will execute every day at midnight.

Saturday, September 10, 2022
 
3

This was the answer:

Use /usr/local/bin/php instead of /usr/bin/php to get codeigniter to pick up on the URI segments.

Sunday, August 28, 2022
 
ffritz
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :