Author Topic: PHP Cron Job  (Read 16201 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
PHP Cron Job
« on: January 31, 2015, 04:40:25 PM »
Trying to run a cron via the crontab in a user account, doesn't seem to trigger the job.
Cron was set to run every 5 mins, and the command line to the php script used is as follows: php -f /home/demo/public_html/cron.php

This however doesn't seem to be working - although the cron saves & shows as active in the webpanel.

Any ideas?

Offline
*
Re: PHP Cron Job
« Reply #1 on: February 04, 2015, 01:41:55 AM »
try using a full path for your php

from command line you can get a full path
which php
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: PHP Cron Job
« Reply #2 on: May 21, 2015, 08:00:56 AM »
Dear All.  This is how my cron job worked.

* * * * * /usr/local/bin/php /home/username/public_html/crontest.php

Offline
*
Re: PHP Cron Job
« Reply #3 on: January 26, 2025, 02:54:33 AM »
Hi in my case on Almalinux it was

* * * * * /usr/local/bin/php -f /targetdir/RunTasks.php >> /targetdir/logs/errors.log &2>1

as I wanted to append >> an error as well however in my case " &2>1" did not work but works perfectly without it!

does anyone know why?

thought I would post this to help others, if you want the error log also include your usual error settings at the head of the script i.e.
in my case wanted everything :)
error_reporting(E_ALL); // Error/Exception engine, always use E_ALL
ini_set('ignore_repeated_errors', TRUE); // always use TRUE
ini_set('display_startup_errors', true);
ini_set('display_errors', true); // Error/Exception display, use FALSE only in production environment or real server. Use TRUE in development environment
ini_set('log_errors', TRUE); // Error/Exception file logging engine.
ini_set('error_log', '/targetdir/logs/errors.log'); // Logging file path