[Linux-disciples] Tweaking cron for network status
Adam Rosi-Kessel
adam at rosi-kessel.org
Fri May 27 16:03:41 EDT 2005
I would have the cron job run a shell script.
Then, in the shell script, I would grep the output of ifconfig to see if
you have an IP address. That's a first pass hack to determine if you're
online or not. Note that it fails in the case where you have a
hard-coded static IP address, or if you used to be online and still have
the DHCP address but now you have lost it.
I can't think of a good test to distinguish between a coffee shop and
not, other than you could build a list of known coffee shop access point
addresses, and grep iwconfig for that to see if that's where you are.
Presumably this wouldn't be too hard since you probably frequent the
same 5-10 public access points most of the time.
You could also do something less automated--just map a key to a shell
script that puts a value in a file for online or offline or semi-online.
Requires human input but is relatively infallible.
Stephen R Laniel wrote:
> I have a couple cron jobs that are sensitive to whether I'm
> online. Fetchmail runs every minute or two, and when it's
> not online it spits out constant error messages. So I'd
> prefer it not to run when I'm not online. And every three
> hours I rsync ~/Mail with a remote server. Not only do I
> want that rsync job not to run when I'm offline, but I'd
> like it not to run when my bandwidth is very low -- like
> right now, when I'm in a coffeeshop and I don't want to
> inconvenience everyone around me.
>
> So I guess I ought to tweak the cron jobs to take note of
> local network conditions. Ideally the tweaks would be
> minimal: rather than
>
> foo();
>
> as they do now, they'd do
>
> if( networkStatus() == {state1|state2|...} ) {
> foo();
> }
>
> So. Any idea where I might find a good set of libraries to
> do tests like this? Testing whether I'm on the Internet's
> probably fairly easy (ping a pingable host), but how do I
> test my bandwidth?
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050527/dcd56362/signature.pgp
More information about the Linux-disciples
mailing list