Cron not running?


#1

I have put a crontab entry as below:
0,5 * * * 0-6 wget -q http://mydomain.com/folder/crawler/crawl.php

Running this on the prompt works. but the script is not executing on its own, every 5 minutes. How can I find out whats wrong and if its running at all


#2

Use the full path for wget: /usr/bin/wget

Oh, and 0,5 means it runs at 0 and 5 after the hour. Use */5 for every five minutes.

-Scott


#3

Thanks for the reponse. I have changed it to this now:

*/5 * * * 0-6 /dh/cgi-system/php.cgi /home/user/mydomain/folder/crawler/crawl.php

But nothing runs still. I have a feeling there is no cron daemon running. Is there a way to check if its running. Running ps does not show cron anywhere in the list of processes.


#4

Decided to change your command arounda little, hmm?

I’m not sure, but I suspect that you need to use a differnet path to php. For your command to run every 15 min, every day of the week, you want it to look like this:
*/5 * * * * /usr/local/bin/php /home/user/mydomain/folder/crawler/crawl.php
Or you can still use wget if you prefer, that would look like this:
*/5 * * * * /usr/bin/wget -q /home/user/mydomain/folder/crawler/crawl.php

The alternative method listed in the wiki, I believe is for choosing which version of php to use for parsing your script. But I’m not really familair with that, so I don’t know.

There is no need to specify days 0-6, using * will tell it just to do it every day.

You should add a
MAILTO="you@dh_hosted_domain.com"
to the top of your cron file so you get error messages. This way you’ll hoepfully get some response from cron to know where you problem is.

The easiest way I know of to test and see if cron is running is to put in a command like this in your cron file:

          • /bad/path/no/file.sh
            and make sure to have that mailto piece at the top. That should set cron to try and run the script every min. Just check your E-mail now. If cron is running, and I’m pretty sure it is, you’ll have an error message waiting for you.

On and side note, you can use the commanand “whereis” to help figure out the ‘full path’ to a program. For instance I logged into SSH for my server and typed:
whereis php.cgi
and it returned:
php: /etc/php /usr/local/bin/php /usr/local/lib/php

I then decided to doucle check the location of wget, so I typed:
whereis wget
and it returned:
wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz

You genearlly want to using the path with bin in it. If you see lib, it’s a backend library, and share is generally for manual pages.

Hope this helps.

–Matttail
art.googlies.net - personal website