Solved

automatic restart

Posted on 1997-04-19
6
247 Views
Last Modified: 2013-12-15
Hi

I am running 3 terminal servers on linux (1 has 4, 1 has 8, and 1 has 16
serial ports). The servers are accessed through a Telnet connection and
do not have their own screens. The problem is that if power goes down
and the system is not shutdown properly we end up restoring the file
system manually by running
        e2fsck -b 8193 /dev/hda3
and the rebooting.
i was wondering if there is any way to make the system run this command
by itself if it detects a corrupted file system and not to require any
user prompt?

the only other solution i see is a UPS....

seva batkin
nortel
0
Comment
Question by:ruski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:hcheng
ID: 1627190
You can write a shell script that upon startup, run e2fsck (or fsck if you want) on the disk without any special repair parameters.  Then, you can check the exit codes (taken from e2fsck's man page):

       The exit code returned by e2fsck is the sum of the follow-
       ing conditions:
            0    - No errors
            1    - File system errors corrected
            2    - File system errors corrected, system should
                   be rebooted if file system was mounted
            4    - File system errors left uncorrected
            8    - Operational error
            16   - Usage or syntax error
            128  - Shared library error

If you see the appropriate exit code, you can run your manual e2fsck command followed by a "shutdown" (after checking the exit code of your manual e2fsck command).

I think UPS is probably the best option if you can afford one.
0
 

Author Comment

by:ruski
ID: 1627191
it doesn't tell me anything new. I still have to check the error codes manually and then run the program by hand.
0
 

Expert Comment

by:virgo21
ID: 1627192
Then you should give him an F.
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 1

Accepted Solution

by:
hcheng earned 100 total points
ID: 1627193
Why would you have to check the error codes manually?  You can check it in your start up script like this:

  /sbin/e2fsck
  if [ $? -gt 0 ]; then
    echo "error detected."
    /sbin/e2fsck -b 8193 /dev/hda3
    if [$? -eq 0]; then
      echo "fixed."
      /sbin -r now
    else
      echo "fix it yourself."
      /usr/bin/login
    fi
  fi

Does this segment do what you want, or am I not understanding what you are asking for?
0
 

Author Comment

by:ruski
ID: 1627194
you see the answer is good, but you still have the "repair it yourself" prompt. I need something that would not require that. TO be done comletely automatically. If there are corrupted files - it fixes them, if there are bad links it fixes them as well.
0
 
LVL 1

Expert Comment

by:hcheng
ID: 1627195
Oh.  I thought that the e2fsck -b 8193 line you gave will always fix whatever problems that you have.  I guess the e2fsck command may also prompts you for input.  If you want to say "yes" to all the questions, you can use the "-y" switch.  Is that what you want?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question