Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automate the download and installation of a hosts file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automate the download and installation of a hosts file
Authored by: robg on Apr 30, '10 05:26:55AM
[The following was submitted as a new hint by an anonymous user; I'm running it here as a comment because it's directly related.  -rob.]



I love the fact the the hosts file is kept up-to-date, but the password prompt bothers me, and I don't really like seeing maintenance scripts like this activate while I'm working. As it turns out, this is very simple to implement via cron.
  1. Download CronniX.
  2. Click the Open button on the toolbar and type in root.
  3. Enter your admin password.
  4. Click on New on the toolbar, and then switch to the Simple tab on the sheet that pops up.
  5. I wanted this to run at 4AM every day, so I left the Minute slider alone, dragged the Hour slider to 4, and checked the other three boxes.
  6. Paste in the following command into the box at the bottom: /usr/bin/cd /etc;/usr/bin/curl -O http://www.mvps.org/winhelp2002/hosts.txt;/bin/mv /etc/hosts.txt /etc/hosts
  7. Click the New button at the bottom of the sheet, and then choose Save on the toolbar at the top to insert this into your workflow.
For those of you who are comfortable with editing the crontab from the command line, you can do it the way I originally did:
  1. Fire up Terminal.
  2. Type sudo crontab -e and enter your admin password.
  3. Press i to place vim into editing mode.
  4. Paste in the following line (replacing my time values below with your preferred time and frequency): 0 4 * * * /usr/bin/cd /etc;/usr/bin/curl -O http://www.mvps.org/winhelp2002/hosts.txt;/bin/mv /etc/hosts.txt /etc/hosts
  5. Hit the Escape key, and then type :wq to write the crontab and quit vim.
To verify your crontab, type sudo crontab -l to see it printed out at the command line.

[ Reply to This | # ]