AdrianSmithUK
asked on
Cron: Not working
OS: Centos 5.4/Plesk
When I run:
#php -q /var/www/vhosts/website.co m/httpdocs /cron.php
cron.php sends me an email.
When I add the following to /etc/crontab - nothing happens.
0-59/1 * * * * php -q /var/www/vhosts/website.co m/httpdocs /cron.php
or
*/1 * * * * php -q /var/www/vhosts/website.co m/httpdocs /cron.php
I tried restarting the cron daemon but still nothing.
What am I doing wrong?
When I run:
#php -q /var/www/vhosts/website.co
cron.php sends me an email.
When I add the following to /etc/crontab - nothing happens.
0-59/1 * * * * php -q /var/www/vhosts/website.co
or
*/1 * * * * php -q /var/www/vhosts/website.co
I tried restarting the cron daemon but still nothing.
What am I doing wrong?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear WoolMilkPork
I tried
*/1 * * * * /usr/bin/php -q /var/www/vhosts/website.co m/httpdocs /cron.php
But still nothing. The PHP file just has:
<?php
mail('test@email.com', 'myTest1', 'myTest1');
?>
Any other ideas?
I tried
*/1 * * * * /usr/bin/php -q /var/www/vhosts/website.co
But still nothing. The PHP file just has:
<?php
mail('test@email.com', 'myTest1', 'myTest1');
?>
Any other ideas?
ASKER
Dear farzanj
The crond service is running.
I tried
* * * * * /usr/bin/php -q /var/www/vhosts/website.co m/httpdocs /cron.php
But still no joy.
The crond service is running.
I tried
* * * * * /usr/bin/php -q /var/www/vhosts/website.co
But still no joy.
ASKER
Dear Kalmax
I tried
* * * * * wget -qb http://www.website.com/cron.php > /dev/null
But no joy I'm afraid.
I tried
* * * * * wget -qb http://www.website.com/cron.php > /dev/null
But no joy I'm afraid.
Next check if it is just this script or it would not schedule anything at all? Try a simple command running every minute.
I have seen this kind of problem with sometimes invisible characters in the cron file. So sometimes location of your line is also important. Put it in the first line. Just another check for weird problems.
Check the user cron file was created
cat /var/spool/cron*/<userID>
Do you see your file?
I would also check if the user has permission over this script to run it.
I have seen this kind of problem with sometimes invisible characters in the cron file. So sometimes location of your line is also important. Put it in the first line. Just another check for weird problems.
Check the user cron file was created
cat /var/spool/cron*/<userID>
Do you see your file?
I would also check if the user has permission over this script to run it.
Could it be that your php.ini is in a non standard location (such as /usr/local/etc), and that you point to this location by means of the PHPRC variable?
If so, please note that this variable is not available under cron and you should either use
* * * * * PHPRC=/usr/local/etc /usr/bin/php -q /var/www/vhosts/website.co m/httpdocs /cron.php
OR
* * * * * /usr/bin/php -c /usr/local/etc -q /var/www/vhosts/website.co m/httpdocs /cron.php
Please note that "/usr/local/etc" is just an example for a possible location of php.ini.
wmp
If so, please note that this variable is not available under cron and you should either use
* * * * * PHPRC=/usr/local/etc /usr/bin/php -q /var/www/vhosts/website.co
OR
* * * * * /usr/bin/php -c /usr/local/etc -q /var/www/vhosts/website.co
Please note that "/usr/local/etc" is just an example for a possible location of php.ini.
wmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks chaps.
WMP was correct - It was the 6th field.
Kind Regards,
Adrian
WMP was correct - It was the 6th field.
Kind Regards,
Adrian
Use full paths inside the php script as well, because cron does not run the user's initialization profile, so there will not be the usual environment.
wmp