Web Hosting Talk







View Full Version : need help with cron!


Surfer
01-03-2002, 06:56 AM
Hi,

I have a script in the cron.hourly folder. It uses the wget command to run a php script on my website. It all works fine, but I receive an e-mail everytime the cron runs my script with wget. In the mail it basically sends the same info as if I would run the script manually in a shell window. Since i don't want to have an e-mail sent every hour of everyday, my question is how can I disable these e-mails?

thanks

cperciva
01-03-2002, 07:07 AM
wget URL > /dev/null

normally cron will not send an email if the command does not produce any output.

Surfer
01-03-2002, 07:59 AM
Thanks for your reply!

This is the command I am using:
wget -O /dev/null http://www.domain.net/script.php

This is in my e-mail:

--04:01:00-- http://www.domain.net/script.php
=> `/dev/null'
Connecting to www.domain.net:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

0K ->

04:01:02 (266.60 KB/s) - `/dev/null' saved [273]


Let me know if you have any ideas?

cperciva
01-03-2002, 08:04 AM
try
wget http://www.domain.net/script.php > /dev/null

Surfer
01-03-2002, 09:18 AM
I tried that and this is the e-mail I got:

--07:01:01-- http://www.domain.net:80/script.php
=> `script.php'
Connecting to www.domain.net:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

0K ->

07:01:02 (266.60 KB/s) - `script.php' saved [273]

cperciva
01-03-2002, 09:57 AM
if you run `man wget` you'll find a list of options for wget... one of them (probably -q) will tell it not to emit those "informational" messages.

priyadi
01-03-2002, 10:24 AM
You have to redirect standard error too. Try this:


wget URL > /dev/null 2>&1

Noldar
01-03-2002, 10:25 AM
Wget may be writing it's ouput to stderr. Try this

wget http://www.domain.net/script.php > /dev/null 2>&1

That will take care of stdout and stderr.

Richard

[Darn, someone was quicker with the submit button :D]

Surfer
01-03-2002, 10:51 AM
Thanks for your input!

With the above configurations it seems to write the HTML output to a file instead of /dev/null! it right to script.php in the same directory as the wget command?!?! My first config didn't do that!?!?

Noldar
01-03-2002, 11:06 AM
Hmmm....OK. I think one of these should do what you want:

wget -q -O /dev/null http://www.domain.net/script.php

If that still gives you an email then try:

wget -O /dev/null http://www.domain.net/script.php > /dev/null 2>&1

Richard

Surfer
01-03-2002, 11:49 AM
Ok,

I tried:
wget -q /dev/null http://www.domain.net/script.php

and it worked!! No e-mail!

What does the -O do? Do I need that extension?

Thanks

Noldar
01-04-2002, 11:19 AM
The -O tells wget where to store the output document. If you just run wget with the following command:

wget http://www.domain.net/script.php

You should end up with a file named script.php. I'm assuming you just want to run script.php and not download it, so:

wget -O /dev/null http://www.domain.net/script.php

The -O tells wget to save the document to /dev/null instead of script.php. The -O is also supposed to turn on quiet mode (-q), but you said earlier that you were using -O and were still getting an email.

So, -O /dev/null should get rid of the script.php file and -q or redirecting stdout and stderr (> /dev/null 2>&1) should get rid of the email.

Richard

Surfer
01-04-2002, 11:56 AM
Thanks for your help!

It all works now...:)