Reynaldi Wijaya Reynaldi Wijaya - 5 months ago 71
Bash Question

Linux cronjob wget to file instead of STDOUT

I have a cronjob that was specified like this :

0 * * * * root bash /data/

Inside this is ->
/data/ 0

As you can see, take two arguments, the first URL and the recursive depth. The script will call another with incremented depth counter and different url which is scrapped from the first run result and stop until it reaches certain depth.

Inside the, I am scrapping a website with this command

wget -O- $1 > main.htm

The problem is, main.htm is not created when this script is run via crontab. The log is saying it is saved to 'STDOUT', while when I manually run it it will save to 'main.htm'. How to solve this?

Answer Source

Output to file by doing the following.

wget -O {output-filename} $1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download