Graphical or automatic "keep-alive" program?

Carl Friis-Hansen ubuntuuser at carl-fh.com
Mon Dec 8 06:27:45 UTC 2008


Edgars Šmits wrote:
> <anthony.rasat at gmail.com> wrote:
>>> I need something that will either automatically function as a keep-alive
>>> program
>> Please bear with because I wrote this in my blackberry. I haven't test it and all.
>>
>> You need to add a line of crontab and write a small shell script. The end result is ping to the gateway 30 times within a minute. I think that should be reasonably small traffic.
>>
>> 0) Login to your wife's user account. Open the terminal application.
>>
>> 1) Make a hidden directory ".script" and change current directory to it:
>>
>> mkdir ~/.script
>> cd ~/.script
>>
>> 2) Write this to file id-gw.sh and make it executable:
>>
>> vim id-gw.sh
>>
>> #!/bin/sh
>> echo `ip ro|grep "default"|cut -f 2 -d " "`

Might give result: "via".
ip ro|grep "default"|cut -f 3 -d " "
would give IP address

>>
>> :wq
>> chmod 755 id-gw.sh
>>
>> 3) Then add this line to account's crontab:
>>
>> crontab -e
>>
>> */1 * * * *     ping -c 30 `~/.script/id-gw.sh` 2>&1 >> /dev/null
>>
>> :wq
>>
>> 4) You're done.
>>
>> Explanation:
>> 1) The script id-gw.sh when executed will notify ping the IP address of the current network default gateway, no matter what network it was at. This gateway is supposed to be reachable unless there is no network available.
>> 2) Crontab line will do the actual ping to that gateway IP address and suppressed any comment or error to the void.
>> 3) The end result, God permitted, would be a series of ping to gateway within one minute, I supposed will keep power management let WiFi awake all the time. And of course, without human interaction.
>>
>> Hope that helps solving your problem.
>>
>> --
>>
> On Wed, Dec 3, 2008 at 2:12 PM, Anthony M. Rasat
> <anthony.rasat at gmail.com> wrote:
>> Back on my desk. There is an error on my earlier response.
>>
>> echo `ip ro|grep "default"|cut -f 2 -d " "`
>>
>> Please change it to:
>>
>> echo `ip ro|grep "default"|cut -f 3 -d " "`
>>
> Anthony: thank you for your solution, it works perfectly. I have been
> running it on both machines this weekend and only lost connectivity
> once.
> 
> Much appreciated, I won't have to run cables through the flat to bring
> the wifi router closer.

Are you really sure your router is pinged?  Because I assume the wrong 
field is extracted in the command. - Strange!

-- 
       +---------------------------------+-------------------+
       | Carl Friis-Hansen               | Fiskeryd Nybygget |
       | http://computingconfidence.com/ | 341 91  Ljungby   |
       | Phone: +46 (0)372 15033         | Sweden            |
       +---------------------------------+-------------------+






More information about the ubuntu-users mailing list