Downloading a File Daily with wget and Cron
Use wget with -O to set the output path and -q to keep cron mail quiet on success. Add retries so a flaky network doesn't skip the day. Always use absolute paths.
The crontab line
0 5 * * * /usr/bin/wget -q -O /data/feed.xml https://example.com/feed.xml
-O writes to a fixed path (overwriting daily), -q suppresses progress so cron only mails you on real errors.
Add retries and a timeout
0 5 * * * /usr/bin/wget -q --tries=3 --timeout=30 -O /data/feed.xml https://example.com/feed.xml
Timestamped filenames
Keep a history by dating the file: -O /data/feed-$(date +\%F).xml. Note: escape % as \% in crontab, or cron treats it as a newline.
FAQ
What cron line downloads a file daily with wget?
0 5 * * * /usr/bin/wget -q -O /data/feed.xml https://example.com/feed.xml. -O sets the output path, -q keeps it quiet.
How do I add retries to a wget cron job?
Use --tries=3 --timeout=30 so a temporary network failure retries instead of skipping the download.
Why does % break my wget cron job?
In crontab, % means a newline. Escape it as \% when using date +%F for timestamped filenames.