简体   繁体   中英

linux apache xml: setup cron-job / automation to retrieve xml

I'm looking to setup a cronjob to automate the process of retrieving a local copy of a non-local xml file. (Every hour is good.)

XML file

https://AAAA-BBBB-CCCC-DDDD:x@myaccount.wufoo.com/api/v3/reports/123456/entries.xml

Local location and rename of file

/home/www/inc/xml/wufoo.xml

You probably want a command that's something like

wget -O /home/www/inc/xml/wufoo.xml https://AAAA-BBBB-CCCC-DDDD:x@myaccount.wufoo.com/api/v3/reports/123456/entries.xml

Your cron entry should look something like

0 * * * * wget -O /home/www/inc/xml/wufoo.xml https://AAAA-BBBB-CCCC-DDDD:x@myaccount.wufoo.com/api/v3/reports/123456/entries.xml

This will run every hour on the hour. If you're going to put it in the system-wide /etc/crontab, be you'll need to include the user to run as:

0 * * * * username wget -O /home/www/inc/xml/wufoo.xml https://AAAA-BBBB-CCCC-DDDD:x@myaccount.wufoo.com/api/v3/reports/123456/entries.xml

In either case, be sure to run as a user with restricted permissions.

Create executable script (root owned) in file: /etc/cron.daily/my-script-name

In that script, use wget command. See "man wget" for details. In general, you will need in that script:

wget -O /path/to/the/local/copy "https://someurl.com/path/to/the/remote/resource"

You may need to use "--no-check-certificate" for "https" protocol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM