Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I am trying to execute wget locally using cron, I have been told by my hosting that due to a local loopback that this won't work?

I am attempting the following command:

wget -q -O /pathtofile/blah.xml "http://myurl/myfeed.php?id=26"

What I am trying to do here is take the output (rss) and save this on my webserver as xml, the way I have been doing this is to open the url and save the source to xml and upload, so I would like to automate this.

Error text:

=> `myfeed.php?id=26'
Resolving myip
Connecting to|myip|:80... failed: Connection refused. 

Is there any thing I can do to achieve this?

share|improve this question
up vote 0 down vote accepted

you can also try to use the --bind-address option.

       When making client TCP/IP connections, bind to ADDRESS on the local machine. ADDRESS may be specified as a hostname or IP
       address.  This option can be useful if your machine is bound to multiple IPs.

and bind to the external ip, instead of the local one.

share|improve this answer
Hi Thanks this is almost working, I get the default RSS but the bind is dismissing the php id variable any ideas? /usr/bin/wget -q -O blah.xml --bind-address= ""; – simon Sep 9 '09 at 13:06

If you can modify myfeed.php to take command line variables as well as $_POST/$_GET then you can just execute PHP from cron:

php /path/to/myfeed.php --id=26

See here for more info on passing args to command line PHP.

You will need to do something like this at the top of your file:

define('CLI', php_sapi_name() == 'cli');

   $input =& $argv;
  $input =& $_POST;

if(isset($input['id'])) // etc...
share|improve this answer

It will work if:

  1. Your web-server is listening on the local interface; and
  2. Your /etc/hosts file has pointing to the local IP.

Otherwise, it will fail. If you can do a netstat -untap and confirm that your web-server is listening on the local interface, it should work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.