[wget] create log file in /root directory

Context :

System : Ubuntu 12.04
Techs : shell(bash)

I have a bash shell script who calls a web service. The web service is wrote in PHP and it will return true if everything is OK.
The method that I execute the calling service is like this :

wget -T 0 http://host/program/myurl > /tmp/mylog

Problem :

Every time I execute the script shell with root, it will generate a file which is called myurl.x (x will be replaced by numbers) in my /root directory instead of in the /tmp/mylog, and this file contains only a number : 1, which I thought it means true.

Solution :

According the option -O of wget which means –output-document, and we make the output file to /dev/null, the command will discard the output message.

So the command will be :

wget -O /dev/null -T 0 http://host/program/myurl

Ref. stackoverflow

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s