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


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

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?


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

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

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.