Issue: wget runs fine from the command line, but fails when in a cron job. My system: SuSE Linux Enterprise Server 9 (SLES9), behind a corporate proxy firewall.
Resolution:
The man page for crontab(5) on my system says:
······ Several environment variables are set up automatically by
the cron(8) daemon. SHELL is set to /bin/sh, and LOGNAME
and HOME are set from the /etc/passwd line of the
crontab's owner. HOME and SHELL may be overridden by setÂ
tings in the crontab; LOGNAME may not.
In addition to LOGNAME, HOME, and SHELL, cron(8) will look
at MAILTO if it has any reason to send mail as a result of
running commands in ââthis'' crontab. If MAILTO is
defined (and non-empty), mail is sent to the user so
named. If MAILTO is defined but empty (MAILTO=""), no
mail will be sent. Otherwise mail is sent to the owner of
the crontab. This option is useful if you decide on
/bin/mail instead of /usr/lib/sendmail as your mailer when
you install cron -- /bin/mail doesn't do aliasing, and
UUCP usually doesn't read its mail.
From the wget man at gnu.org, I read:
Wget supports proxies for both http and ftp retrievals. The standard way to specify proxy location, which Wget recognizes, is using the following environment variables:
http_proxy
https_proxy
If set, the http_proxy and https_proxy variables should contain the urls of the proxies for http and https connections respectively.
Of course, I knew that I was behind a corporate proxy server, and "echo $http_proxy" returned the correct URL for the proxy server. So, for my purposes, I created a simple script named wget.sh
#!/bin/sh
export http_proxy="http://your.server.here:8080"
wget ...etc, etc.
Then I put a crontab entry in place, calling my wget script. Works like a charm!


Comments