How To Use Cron to Access Remote Script

From the shell you can use programs like wget and curl to access a remote script, however the same commands would fail when added to crontab. Here are my tips to get them to work:

  • Include the path to the executable i.e. /usr/local/bin/wget
  • Use the quiet/silent option when possible
  • If the URL you wish to use includes parameters (?var=value) enclose the URL in double or single quotes
  • Redirect output to a log file to verify operation

Here is how to use both wget  and curl within crontab:

# run every five minutes
*/5     *       *       *       *        /usr/local/bin/wget -qO /var/log/cron.wget.log ""
# run on the hour
0       *       *       *       *       /usr/local/bin/curl -s "" > /var/log/cron.curl.log



No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *