PDA

View Full Version : Cron


jsnelling
01-20-2007, 09:02 AM
Hi I'm new to the world of Cron, I'm trying to run a script once a day that sends out an e-mail. When I use SSH and run php -q /var/www/vhosts/johnsnelling.com/httpdocs/mail.php I get the email no problem. when I put it in a crontab nothing happens. Any insight would be much appreciated.

Thank You,

John Snelling

Daniel
01-20-2007, 11:20 AM
What are you currently using for your cron?

jsnelling
01-20-2007, 11:36 AM
I've tried a couple: During testing I had it run every minute (stopped after 5 minutes)
*****php -q /var/www/vhosts/johnsnelling.com/httpdocs/mail.php
*****wget -q -O /dev/null http://www.johsnelling.com/mail.php

I deleted them when they didn't work. I've also read that I should check to see if Cron is active but I'm not quite sure how to do that.

Thanks,

John

Daniel
01-20-2007, 08:35 PM
John,

There's a few things you can do and you need to check.

Firstly.. does that script have the following line at the top? (assuming it doesn't need to be accessed by the internet, only by your cron)

#!/usr/local/bin/php -q

The above is assuming that your path to php is /usr/local/bin/php. This makes it more of a "shell" script, than a PHP script, if you know what I mean. THen you should just be able to go into Plesk and use:

* * * * * php /var/www/vhosts/johnsnelling.com/httpdocs/mail.php

For every minute. Also make sure the script has sufficient permissions to be executed (755 should do it).

To check if crond is running you can run the following from SSH (as root):

service crond status

If it's not running, you can do a:

service crond start

Then

ps aux|grep crond

and make sure it started up. The above should have it work for the most part. You can always check the cron logs to see if it is or not, and if not.. you can submit a ticket so we can look at it closer to find out what's going on. :)

Keep in mind that if you don't make the cron using Plesk... it will most likely be overwritten soon since Plesk likes to do that sort of thing when it updates its internal database.

jsnelling
01-20-2007, 09:53 PM
Thanks the service wasn't running.

jsnelling
01-25-2007, 08:06 PM
Do you know why a service like cron would stop? It stopped sometime between 1:11 AM Yesterday Morning and 1:11 AM this morning.

Daniel
01-26-2007, 01:35 AM
Do you know why a service like cron would stop? It stopped sometime between 1:11 AM Yesterday Morning and 1:11 AM this morning.
It may have been killed due to you hitting the resource limit,s or if it seg faulted. If you open a ticket up, we should be able to find the cause. :)