Solved

automatic restart

Posted on 1997-04-19
6
243 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
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:hcheng
Comment Utility
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
Comment Utility
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
Comment Utility
Then you should give him an F.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Accepted Solution

by:
hcheng earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now