0

Good morning,

I have a home server running Ubuntu 14.04.3 LTS. It's a desktop connected to my wi-fi connection via an USB adaptor. The issue here is that randomly it gets disconnected from the network and asks again for the password (which is always the same and correctly stored, in fact it's already typed in the dialog that pops up) and I have to manually click or press enter to connect it again.

I have added to my crontab this small script

#!/bin/bash

if ! [ "$(ping -c 1 google.com)" ]; then
    service network-manager restart
fi

it runs every 5 minutes

*/5 * * * * /home/***/keepalive.sh

but it does not seem to help and i often find my server disconnected. What am I doing wrong?

1

Replace service with the full path to service binary i.e. /usr/sbin/service:

#!/bin/bash
if ! [ "$(ping -c 1 google.com)" ]; then
    /usr/sbin/service network-manager restart
fi

Also put this in root's crontab as restarting network-manager requires root privilege, alternately you can grant yourself password-less sudo access for this command only, then you can use sudo /usr/sbin/service network-manager restart.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.