Linux cronjob wget to file instead of STDOUT

时间:2017-10-03 09:01:16

标签: linux bash shell cron wget

I have a cronjob that was specified like this : 0 * * * * root bash /data/daily.sh

Inside this daily.sh is -> /data/get.sh https://www.xxxxxxx.com/ccc/ 0

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

Inside the get.sh, 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?

1 个答案:

答案 0 :(得分:1)

通过执行以下操作输出到文件。

wget -O {output-filename} $1