Cpanel, User Cron jobs not appearing in cron log - php

We recently did a large server migration, and for some reason cron isn't working as expected on the new system. Some cron scripts are running as normal but others don't seem to be executing at all.
If I look at the old server and tail the cron log /var/log/cron, I can see cron scripts executed as they should.
On the new server, none of the user cron execution shows up in the log. I can see general cron messages for user accounts, and I can see ROOT crons running, but no information on user crons other than general messages such as LIST, REPLACE, etc.
I've checked permissions on the files being executed. Some of the scripts log to files or send emails, so I know that some are running and some aren't. I've also verified the cron jobs are located in /var/spool/cron.
Most of these are php scripts, and the only change we made on this server vs. the other one is running apache using mpm-itk. This shouldn't be the problem though since file permissions weren't changed and shell is running php cli.
Would be a lot of help if I could verify the scripts are being executed. No errors in apache or other logs that I can find. Any suggestions would be appreciated.

Related

Cron Scheduling Stopped Suddenly

Magento Enterprise Ver : 1.13
My cron scheduler has stopped suddenly.
When i checked cron_scheduler table i am not getting any entry there after 16th Jan.
I have tried a lot but unable to find any lead regarding what would have stopped it.
Its not scheduling jobs after running the cron.php manually also.
Hence please suggest if any one knows where to look or any way to track down the problem.
Refrence : cron.sh is having 777 permission
Run $ crontab -e on your server and check your cron configuration.
You can add MAILTO=your.email#example.com at the beginning of the file to send an email for every cron that is fired.
You'll probably get the error message there.

filesize function fails when run from cron

I get the below error when I run my scrip from cron
Warning: filesize() [function.filesize]: stat failed for /home2/sharingi/public_html/scrape/zip/dailydose/April_14_2011.zip in /home2/sharingi/public_html/scrape/zip/zip.php
However if I run the script from my browser it works fine. Some kind of a permissions problem?
It's probably an issue related to the user that your cron process runs under. Make sure that whatever cron runs as has permissions, since it's probably not the same user as your ssh account or the webserver account. You can probably figure out which user cron runs as by configuring cron to run the command whoami and email you the output.
If you can't figure out how to make that work, you might try configuring cron to wget the public url that you know works. Don't forget to turn off the file saving, and set it to quiet mode, otherwise you'll get a lot of garbage from each run.
if you're in a shared hosting environment, your cron job is probably running as your own user, so unless you yourself don't have read permissions for the file in question, I imagine that's probably not the issue.
As a probable work-around, in case you can't get to the bottom of it easily, here's a function which should allow you to get the info you need without using the php-builtin.

CRON jobs keep erroring

We have several CRON jobs running on our apache / whm server. We are using php. The scripts all work completely fine when run from the browser.
The cron will throw back errors like: unable to include files (even when giving the absolute path).
Results will also vary, corrupting output files etc. I am really baffled, as sometimes the crons work fine as well. Seems really intermittent and they work every time perfectly when executed from the browser.
Any help would be appreciated, cheers.
As everyone has pointed out, PHP CLI and the PHP Apache Module are separate software and they have separate configuration files.
Rather than set the crontab up on the root cron tab, make sure all your permissions are correct. Debug with the user they will run from cron as. Assuming you are running Linux, you can use
sudo -i -u username
for this.

Cron Jobs stopped working

I've been running a daily cron job for a few months and it was working fine.
The cron job runs a php script that does a database action then mails my email address with the results.
Suddenly a few days ago, when the script ran, the database action stopped working, but it would send me the email. I changed the php script to send a different email, but it still sends me the old one.
I can't seem to get any new scripts to run and when I set up an email address for the cron job to run it doesn't send one.
Any thought as to how I can get this back on track?
More information:
I use a linux OS cPanel.
I've used the following commands.
/usr/bin/php -f /home/[user]/public_html/[path to script]
/usr/bin/php -q /home/[user]/public_html/[path to script]
/usr/local/bin/php -f /home/[user]/public_html/[path to script]
/usr/local/bin/php -q /home/[user]/public_html/[path to script]
PHP says that the path to PHP is /usr/bin/php however, it used to work with the local part in there.
#DampeS8N- I'd rather not. The PHP script just includes a few sql commands and a mail function. It works fine without any errors when visited by browser.
#Paul- That is what I am inclined to believe. I think the Cron Daemon is stuck somehow. When I try to add new cron jobs, they don't register as going off, and it won't send emails to my email address when a cron should go off.
I am a complete newbie to cron. I access cron jobs in my cPanel X. I'm pretty sure I don't use crontab. Detailed instructions for any actions you'd like me to take would be great.
Well, I wound up contacting my hosting support. Turns out the domain was moved to a new server and the cron jobs were still running on the old one.

script runs fine when run from command line but not via cron

i have a php script which runs fine when executed by SSHing into my server and running it.
however the php script doesn't seem to run even though a cron job set to run it every 10 minutes.
How do I view errors produced by cron job ?
Remember that cron runs your script in a different working directory than what you're probably used to. Try something like the following on the command line:
cd /
./path/to/your/script.php
If it fails, modify all paths in your script correctly until it runs. Then it will run in cron.
Sometimes, the error messages are emailed to you by cron. Otherwise, it probably gets sent to a hapless system administrator who probably scrupulously saves the messages in /dev/null.
When things work from the command line and do not work from cron, the 'environment' is almost always at fault. Something that is set in the normal command line environment is not set in the cron environment. Remember, cron does not run your profile for you - you have a bare minimal set of environment variables with bare minimum values for things like PATH.
Generally, I assume that I should run a shell script from cron, and that shell script is responsible for ensuring the correct environment is in place - and that errors are trapped and logged appropriately - before running the main part of the software.
not sure but it's probably credentials related. Schedule your task to run with your user ID and see if that doesn't clear it up. If so, you'll need to create a set of "batch" credentials that you can use to schedule tasks to run beneath.

Categories