|
|
not as simple as I am!
As in the hint at top, I've been doing a similar time-switching of half the home network to control net access for some time, but this 'cron' approach sounds perfect to tailor it a little more to individual users ...
not as simple as I am!
Okay i'll help you, but rather than give you the answer I'll help lead you through it.
First cron is a fairly easy syntax and the global root cron is located in /etc/crontab and it has a man page for it's syntax. (There's also user level crons in /var/crontab). But the modern way is now to use launchDeamon which has a more complex syntax that is both self documenting and a little intimidating. TO see how to do this look in cat /System/Library/LaunchDaemons/com.apple.periodic-daily.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.apple.periodic-daily</string> <key>ProgramArguments</key> <array> <string>/usr/sbin/periodic</string> <string>daily</string> </array> <key>LowPriorityIO</key> <true/> <key>Nice</key> <integer>1</integer> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>3</integer> <key>Minute</key> <integer>15</integer> </dict> </dict> </plist> So you just copy this twice, make one called blocker.plist and one called unblocker.plist in blocker,plist change the program arguments array to <string>/usr/local/bin/waxon_off.pl </string> <string>off</string> change the time to <key>Hour</key> <integer>8</integer> in unblocker set things to change the program arguments array to <string>/usr/local/bin/waxon_off.pl </string> <string>on</string> change the time to <key>Hour</key> <integer>17</integer> Now we need to create waxon and waxoff copy and paste the following into a terminal cat >/usr/local/bin/waxon_off.pl /usr/bin/perl -w open FH, "/etc/hosts.orig"; @S = <FH>; close FH; open FH, "/etc/hosts"; print FH, @S,"\n"; if (@ARGV[0] eq "off") { print FH<<EOF; 127.0.0.1 slashdot.org apple.slashdot.org 127.0.0.1 macosxhints.com EOF close FH; } Then execute: sudo cp /etc/hosts /etc/host.orig chmod a+x /usr/local/bin/waxon_off.pl There. now you will turn things off at 8 am and turn things back on at 5 pm if you want to revert this remove the plist file and then restore the original hosts file like this. sudo cp /etc/hosts.orig /etc/host if you want to override it manually use /usr/local/bin/waxon_off.pl off edit the segment print FH<<EOF; 127.0.0.1 slashdot.org apple.slashdot.org 127.0.0.1 macosxhints.com EOF to include whatever sites you want blocked.
typo fix
copy and paste the following into a terminal
typo fix again
copy and paste the following into a terminal
typo fix again
Hi, |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.14 seconds |
|