LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-13-2008, 09:52 PM   #1
grande25
LQ Newbie
 
Registered: Oct 2008
Posts: 29

Rep: Reputation: 15
Reboot Linux Client on Network Disconnect


Question: Is there a way to force a reboot on a remote linux client when connection with the server is lost/broken?

Background: Server sends IP Video to Linux client. When power is lost or network goes down, the Linux client continues broadcasting the last server transmission which is BAD. If I could restart the Linux client it would cease to transmit the outdated info and be ready to post updated data when power/network connectivity is restored.

Iz
 
Old 10-14-2008, 02:12 AM   #2
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 655

Rep: Reputation: 40
You could make a cron-job that checks the network status (and other things as well) every X minutes, and reboots if it finds an error.

Another thing would be to use a network power switch. That way you could (automatically) log into the power switch and reboot the failed server.

I'm sure there are plenty of other ways to do this, but it depends on your current setup and so forth.
 
Old 10-14-2008, 02:47 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
You only need to restart the network service. This isn't Microsoft.
 
Old 10-19-2008, 09:40 PM   #4
grande25
LQ Newbie
 
Registered: Oct 2008
Posts: 29

Original Poster
Rep: Reputation: 15
Any help on this script?

Okay, I'm using VI and this is the first script I've ever run. I can get the script to run and it pings the server IP just fine. Problem is when I unplug the server and the IP pings fail it doesn't execute the reboot as I'm trying to make it. I've adjusted priveleges to be sure users can run the command. I'm getting a syntax error that i'm making an "unexpected end of file" argh! Here is the script I have:

Ping -n 123.45.678.910
if %errorlevel%==4 shutdown -ar -t 5









When i run this script and the server is connected to the LAN i get a nice steady stream of pings. When I unplug the cable the stream stops and what should happen is a reboot. However it just sits there. When i hit Ctrl+C to stop the script it gives me the syntax error: unexpected end of file.

Please help
 
Old 10-20-2008, 09:20 AM   #5
grande25
LQ Newbie
 
Registered: Oct 2008
Posts: 29

Original Poster
Rep: Reputation: 15
Any suggestions?

Bumping...
 
Old 10-20-2008, 07:00 PM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
I don't recognise this syntax

if %errorlevel%==4 shutdown -ar -t 5

looks like DOS batch cmd.

Try reading these:
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html


I'd recommend sending 1 ping, then checking the exit code eg
Code:
broadcast="up"
while true
do
    ping -c 1 123.45.678.910>dev/null 2>&1
    if [[ $? -ne 0 ]]
    then
        if [[ $broadcast = "up" ]]
        then
            <stop broadcast program>
            broadcast="down"
        fi
    else
        if [[ $broadcast = "down" ]]
        then
            <start broadcast program>
        fi
        broadcast="up"
    fi
done
no need to reboot anything. Optionally you'd want a sleep cmd at the bottom of the loop, otherwise it'll hammer the cpu. Sleep is normally in seconds eg

sleep 10

sleep for 10 secs.

Last edited by chrism01; 10-20-2008 at 07:04 PM.
 
  


Reply

Tags
conditional, linux, network, reboot


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GUI for Client/Network mgmt with Linux+Samba for WinPC network ?? Mel_3 Linux - Server 1 11-15-2007 08:59 AM
i have to disconnect internet to get on network Niflheim Linux - Networking 1 02-03-2005 06:44 PM
Cannot disconnect modem from rh-config-network slackist Linux - Networking 3 05-02-2004 07:50 AM
network disconnect slackware void4ever Linux - Networking 2 02-19-2004 08:27 PM
how to disconnect a client connect by proxy squid? echox Linux - Software 0 04-06-2003 08:35 PM


All times are GMT -5. The time now is 01:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration