Setting up a cron job



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

*/5 * * * * wget

This is the error i am getting in my mailbox


=> `mail.php’
Connecting to[]: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 :slight_smile:


Are you editing the file in the shell or uploading from your own machine?

:cool: [color=#6600CC]Atropos[/color] |


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.


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



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"

"*/5 * * * * /usr/bin/wget"


DOH! Sorry for what is essentially a redundant post. I compose my replies in a text editor first, then paste them.


Hey people, thanks for all the suggestions. The problem has been solved now by dreamhost support!