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

Automatically change network locations with a cron job Network
I've gotten tired of having to change my location every time I open my notebook at home or at school/work. So I have adjusted my crontab as follows:

 0      8       *       *       1,2,3,4,5       scselect School
 40     14      *       *       1,2,3,4,5       scselect Home
Translated, I have it change my network location to School every weekday at 8 AM (the time I'm scheduled to be at school) and back to my Home location when I'm expecting to be home from school.

The only catch is that I don't think this will execute when my computer is asleep (unless this changed with Panther), so I used Fink to install anacron which executes cron commands as soon after their scheduled times as possible, rather then right at the scheduled time.
    •    
  • Currently 2.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[6,833 views]  

Automatically change network locations with a cron job | 8 comments | Create New Account
Click here to return to the 'Automatically change network locations with a cron job' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically change network locations with a cron job
Authored by: by on Nov 13, '03 12:05:34PM

Hi,

Isn't it that the smallest cronon that Anacron is using is one day, meaning, you cannot schedule something to run "at 2pm or after"? - IMHO, you can only specify the day/date (see man anacron):

"Anacron can be used to execute commands periodically, with a frequency
specified in days. Unlike cron(8), it does not assume that the machine
is running continuously. Hence, it can be used on machines that aren't
running 24 hours a day, to control daily, weekly, and monthly jobs that
are usually controlled by cron."

Best regards,
Michael



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: William McCallum on Nov 13, '03 12:24:12PM

No, Anacron runs its jobs soon after waking up, if they haven't yet been run for that day (or week, or month). I believe it uses the delay set in the "delay" colum of the file anacrontab (although I've never actually checked that).



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: jpbjpbjpbjpb on Nov 13, '03 01:18:25PM

Yes, it runs jobs when the machine wakes up, but that doesn't mean you have a higher granularity than a day, it won't run jobs unless it's been at least 24 hours since the last time it ran.

There is no way for you to specify with anacron for things to be run at a specific time, just that they be run at least every N days.



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: turkchgo on Nov 13, '03 01:07:54PM

So how does Apple handle this for the maintenance tasks on notebooks? I've noticed that most the cron jobs Apple uses to roll logs and cleanup the UNIX output are set to run at specific times of the month, week and day and usually early in the morning or late at night. If you have an iBook, like I do, and you almost never have the thing running for more than a few daytime hours at a time, how and when do these things get executed? Or is it advisable to one day a month let your iBook run and not sleep overnight?



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: housemaister on Nov 13, '03 01:26:03PM

You can use anacron to run these scripts in the 'necessary' periods. You can also use XJanitor, a perl script, for doing this.



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: rammjet on Nov 13, '03 03:27:47PM

They DON'T get run. That is why there are so many 3rd party utilities to either run the CRON jobs manually or to reset the times to when the user might be running the computer.



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: encro on Nov 14, '03 08:44:11AM

You can do it any time you feel by typing one of the following into the terminal:

sudo periodic daily

sudo periodic weekly

sudo periodic monthly



[ Reply to This | # ]
Automatically change network locations with a cron job
Authored by: Hes Nikke on Nov 13, '03 04:43:56PM
credit where credit is due i guess it helps to mention that i got the scselect idea from chabig's reply to my question on how to change IPs remotely. i don't recall where i heard heard about anacron though

---
vacuums do not suck. they merely provide an absence that allows other objects to take the place of what becomes absent.

[ Reply to This | # ]