Current time: 04-24-2014, 12:45 PM Hello There, Guest! (LoginRegister)

Post Reply 
Setting up a cron job
10-08-2006, 08:36 AM
Post: #1
Setting up a cron job
Hello,

Im trying to make cron run a PHP file every 5 minutes, this is the command im currently trying to use.

MAILTO="myemail@gmail.com"
*/5 * * * * wget http://mysite.com/mail.php

This is the error i am getting in my mailbox

--04:20:59-- http://mysite.com/mail.php

=> `mail.php'
Resolving mysite.com... 208.113.148.68
Connecting to mysite.com[208.113.148.68]:80... connected.
HTTP request sent, awaiting response... 404 Not Found
04:20:59 ERROR 404: Not Found.

As you can see cron automatically put '' after the source path, thats why it cant be found. I am suspecting the extra blank line i put in the cron command is causing this, but when i leave the blank line out of it, the cron command does not run at all.

Thanks for any help in advance Smile
Find all posts by this user
Quote this message in a reply
10-08-2006, 09:30 AM
Post: #2
Setting up a cron job
Are you editing the file in the shell or uploading from your own machine?

Cool Atropos | openvein.org
Visit this user's website Find all posts by this user
Quote this message in a reply
10-08-2006, 09:44 AM
Post: #3
Setting up a cron job
Thanks for the reply.

Since editting directly in the command prompt doesnt work for me (when i use crontab -e i get a whole lot of gibberish and i cant get out unless i close the window) i put the cron command in a txt file and uploaded it to my root directory. I then ran 'crontab /home/*username*/cron.txt' in the command promt. When running crontab -l it does show the command how it should be.
Find all posts by this user
Quote this message in a reply
10-08-2006, 10:04 AM
Post: #4
Setting up a cron job
Have you tried running that wget command from the command line? It looks like the cronjob is running, but there's something wrong with the wget. Does mail.php need some parameters, such as mail.php?to=you&from=me, etc.?

Also, when I set up a cronjob, I use full paths just for assurance:
*/5 * * * * /usr/bin/wget http://mysite.com/mail.php

-Scott
Find all posts by this user
Quote this message in a reply
10-08-2006, 10:27 AM
Post: #5
Setting up a cron job
Due to the space where these jobs execute, you usually have to include the full path to the command you want to run. When I was setting up a cron job for my stats, which runs a perl script, "perl *scriptname*" didn't work. I had to use "/usr/local/bin/perl *scriptname*". While in the shell, do a "which wget". For me it comes back as "/usr/bin/wget".

So instead of:
"*/5 * * * * wget http://mysite.com/mail.php"

Try:
"*/5 * * * * /usr/bin/wget http://mysite.com/mail.php"

http://benconley.net
http://teamshocker.com
Find all posts by this user
Quote this message in a reply
10-08-2006, 10:28 AM
Post: #6
Setting up a cron job
DOH! Sorry for what is essentially a redundant post. I compose my replies in a text editor first, then paste them.

http://benconley.net
http://teamshocker.com
Find all posts by this user
Quote this message in a reply
10-09-2006, 12:44 PM
Post: #7
Setting up a cron job
Hey people, thanks for all the suggestions. The problem has been solved now by dreamhost support!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: