I made a couple of mistakes in my cron job list that kept this from working properly. I didn't need the user component of the command, and "5 pm" is actually hour "17", so the two commands should read:
# # Move to the restrictive hosts to keep users off waste sites for the workday
0 9 * * 1-5 cp /etc/hosts.work /etc/hosts
# After 5:00 p.m., return the free "home" hosts file:
# Move the hosts file back to full access at the end of the workday
0 17 * * 1-5 cp /etc/hosts.home /etc/hosts
However, one not so nice thing about OS X's implementation of cron is that it won't work if the computer is in Sleep mode. On most Linux systems, this problem is dodged by using 'anacron' which will execute any cron jobs missed while the computer was off or asleep, but apparently OS X doesn't include anacron. The workaround is to modify the times to reflect accurately when I will have the system up and running, so now my crontab listing becomes:
# # Move to the restrictive hosts to keep users off waste sites for the workday
0 10 * * 1-5 root cp /etc/hosts.work /etc/hosts
# After 5:00 p.m., return the free "home" hosts file:
# Move the hosts file back to full access at the end of the workday
30 16 * * 1-5 root cp /etc/hosts.home /etc/hosts
I'll let you know how it pans out over the next week.
No comments:
Post a Comment