Web Hosting Talk







View Full Version : Crontab problem


WebDesigner-EU
03-17-2005, 02:26 AM
I got at crontab problem. I'm trying to setup a cron to run every minute, but it does not work. When I check the crontab log I can see that the cronjob has run, but since I'm testing a simple php mail script and I don't recive any mail - it has not run!
The php script is simple enough, <?php mail("me@server.com", "Subject", "Content"); ?>

The conrtab looks like this:
* * * * * php /home/user1/public_html/mailscript.php

And if I run just php /home/user1/public_html/mailscript.php the scripts sendt me a mail. But not when I set up a crontab!

X-TechMedia
03-17-2005, 05:50 AM
How are you setting the crontab up?
Through a control panel, or through SSH?

artofmobile
03-17-2005, 06:21 AM
Do this:

1 * * * * php /home/user1/public_html/mailscript.php >/home/user1/public_html/out.txt 2>/home/user1/public_html/err.txt

Check the out.txt and err.txt to see what error you see.

The reason why I use "1 * * * *" in my example is just in case the output files are replaced before you can copy to some where else.

fastduke
03-17-2005, 05:27 PM
Originally posted by artofmobile
Do this:

1 * * * * php /home/user1/public_html/mailscript.php >/home/user1/public_html/out.txt 2>/home/user1/public_html/err.txt

Check the out.txt and err.txt to see what error you see.

The reason why I use "1 * * * *" in my example is just in case the output files are replaced before you can copy to some where else.

Or you could just append to the file ;)

* * * * * php /home/user1/public_html/mailscript.php 2>> /home/user1/public_html/err.txt

nulled
03-18-2005, 08:54 PM
Besure to include the REAL path to the php binary.

Typically this will be /usr/bin/php