peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
811 stars 144 forks source link

CRON JOB not running automatically but run manually #112

Closed sarabhi92git closed 4 years ago

sarabhi92git commented 4 years ago

Hi, I have added the similar command in cron tab with correct path and cron job is also running but the output is not writing in a log file.

But if I run the command manually then scheduler.php is writing the output in log file.

* * * * * path/to/phpbin path/to/scheduler.php 1>> /dev/null 2>&1

Please help me where I am wrong

peppeocchi commented 4 years ago

Hi @sarabhi92git have you already checked the server for error logs? Can you see your cronjob in the crontab? (crontab -l) Please make sure your log file is writable by the user executing the cron. It's hard to say why your cronjob is not running, I would try to have a look at the crontab logs https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log to see if it's really executing or if there are errors in the execution.

Closing as this is not an issue with the package itself, but by looking at the logs you should be able to see why it's not running. If the crontab logs doesn't show any execution, or if your cronjob is not in the crontab, then that's your issue. Otherwise you can have a look at your server logs to see if there is any file permission issue

sarabhi92git commented 4 years ago

Hi @peppeocchi , I have checked crontab -l and also checked server cron log and cron job is executing and do not show any error.

But I have added in cron scheduler to write output file after cron job completed but the output file is not generated.

This is my code $scheduler->call(function () { echo "Hello"; return " world!"; })->output('my_file.log'); $scheduler->run();

peppeocchi commented 4 years ago

Check the file location and that the user executing the cronjob has permission to write it, you can also create the log file and give permissions to all users