|
Subject
|
Setting up a cron job
|
| | Posted by | -Av (DH New User
) | | Posted on | 10/08/06 08:36 AM |
|
|
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 :)
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: -Av]
|
| | Posted by | Atropos7 (DH DreamNinja) | | Posted on | 10/08/06 09:30 AM |
|
|
Are you editing the file in the shell or uploading from your own machine?
Atropos | openvein.org
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: Atropos7]
|
| | Posted by | -Av (DH New User
) | | Posted on | 10/08/06 09:44 AM |
|
|
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.
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: -Av]
|
| | Posted by | sdayman (DH Grizzled Veteran) | | Posted on | 10/08/06 10:04 AM |
|
|
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
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: -Av]
|
| | Posted by | pangea33 (DH Enthusiast) | | Posted on | 10/08/06 10:27 AM |
|
|
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
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: sdayman]
|
| | Posted by | pangea33 (DH Enthusiast) | | Posted on | 10/08/06 10:28 AM |
|
|
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
|
|
|
|
Subject
|
Re: Setting up a cron job
[re: -Av]
|
| | Posted by | -Av (DH New User
) | | Posted on | 10/09/06 12:44 PM |
|
|
Hey people, thanks for all the suggestions. The problem has been solved now by dreamhost support!
|
|
|