Search code examples
phpcroncpanel

Run a PHP file in a cron job using CPanel


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?


Solution

  • 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