Analyze the normal shutdown command under Linux system

  


Here is a question for judging the normal shutdown of Linux. Xiaobian collected some information for everyone to see, I hope everyone can get help from it.

when the system starts to generate a file, linux, when the normal shutdown will delete this file. The network administrators can judge whether the abnormal shutdown is based on whether there is a file at the time of booting the system, and reduce the probability of failure in the network management process.

steps:

in /etc/rc.d/init.d/programming scripts. !

determine whether the normal shutdown, and generate a script file: touch-file.sh

# /bin /sh file = /tmp /check if [-e $]; then echo " this is not normal shutdown "

& gt; & gt; /var /log /checkmessage else echo " this is normal shutdown and touch file "

& gt; & gt; /var /log /checkmessage touch script under $ fi

linux normal shutdown deleted files: rm-file.sh

# /bin /sh file = /tmp /check echo " this is normal shutdown and! rm file "

& gt; & gt; /var /log /checkmessage rm -rf $

the script automatically.

ln -s /etc/rc.d/rc0.d/K01rm-file /etc/rc.d/init.d/rm-file.sh

Note:

#ll /etc/rc.d/rc0.d/

soft on both sides of the connection it a name which is not the same, after a path can be absolute or relative path, do ensure that both sides of the name Different.

ln -s /etc/rc.d/rc6.d/K01rm-file /etc/rc.d/init.d/rm-file.sh ln -s

/etc /rc.d/rc3.d/S01touch-file /etc/rc.d/init.d/touch-file.sh

my system is useless to the x-window, so there is no level5, that is, There is no need to drop the script in /etc/rc.d/rc5.d/.

special attention:
beginning
K representative system shut down when the execution on behalf of the beginning of the S boot time execution. Pay attention to the specification of server scripting, because the soft link opened by K does not necessarily execute automatically when it is shut down. Why is this? When executing K script, it will query whether there is K with /var/lock/subsys/. The empty file name with the same name as the opening script, if not, will not be executed. Therefore, according to the specification of the server script, when starting, touch an empty file with the same name as K01 in /var/lock/subsys/:

# /var /lock /subsys #touch fm-file

over to you on that judgment in the normal shutdown of linux.

Copyright © Windows knowledge All Rights Reserved