开发者

Using wget in a crontab to run a PHP script

I set up a cron jo开发者_开发技巧b on my Ubuntu server. Basically, I just want this job to call a php page on an other server. This php page will then clean up some stuff in a database. So I tought it was a good idea to call this page with wget and then send the result to /dev/null because I don't care about the output of this page at all, I just want it to do its database cleaning job. So here is my crontab:

0 0 * * * /usr/bin/wget -q --post-data 'pass=mypassword' http://www.mywebsite.com/myscript.php > /dev/null 2>&1

(I post a password to make sure no one could run the script but me). It works like a charm except that wget writes each time an empty page in my user directory: the result of downloading the php page.

I don't understand why the result isn't send to /dev/null ? Any idea about the problem here? Thanks you very much!


wget's output to STDOUT is it trying to make a connection, showing progress, etc.

If you don't want it to store the saved file, use the -O file parameter:

/usr/bin/wget -q --post-data -O /dev/null 'pass=mypassword' http://www.mywebsite.com/myscript.php > /dev/null 2>&1

Checkout the wget manpage. You'll also find the -q option for completely disabling output to STDOUT (but offcourse, redirecting the output as you do works too).


wget -O /dev/null ....

should do the trick


you can mute wget output with the --quiet option

wget  --quiet    http://example.com
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜