A file is generated when the system is started, and will be deleted when the system is shut down normally. 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:
Program the script in /etc/rc.d/init.d/.
To determine if the shutdown is normal, and the script that generates the file: touch-file.sh
#!/bin/sh file=/tmp/check if [ -e $ ];then echo " ;this is not normal shutdown"
>>/var/log/checkmessage else echo "this is normal shutdown and touch file"
>>/var/log/Checkmessage touch $ fi
Script to delete files normally: rm-file.sh
#!/bin/sh file=/tmp/check echo "this is normal shutdown and rm file" ;
>>/var/log/checkmessage rm -rf $
Let the script execute 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/
The names of the two sides of the soft connection are not the same. The latter one can use absolute or relative paths. 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 doesn't use x-window, so there is no level5, which is There is no need to drop the script in /etc/rc.d/rc5.d/.
Special Note:
When K starts, the system is executed when it is closed, and the beginning of S is executed when it is turned on. 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 of the same name of the opening script, if not, will not be executed, so according to the specification of the server script, when starting, touch an empty file with the same name behind K01 in /var/lock/subsys/:
#/var/lock/subsys #touch fm-file
Executing programs are called processes. When a program is stored in an executable file and is runni
“ A real programmer does not need an IDE. They all use a text editor with a plugin to write c
Cant write data on the hard disk of Linux or UNIX-like systems? Want to solve the problem of disk co
win7 There are a lot of tricks, if used well, can make the win7 system get no small optimization. No
CentOS 6.4 install oracle 11G environment preparation
Optimization (configuration file) in nginx instructions
Linux system Ghost into Windows XP error
Linux sort command parameters and usage details
Novice Academy: Ways to Add Linux to Windows Domain
After installing xen, the boot will be black, what happened?
The relationship between spinlock and linux kernel scheduling
XXX is not in the sudoers file. This incident will be report
Libsasl2.so.2 can not be found, apache can not start
Several commonly used Linux operating system monitoring scripts
How to open Win10 sleep mode? Win10 sleep mode open tutorial
PPT animate also plays with rotation.
Web Server Setup Raiders for FreeBSD Platform
Win7 Ultimate expansion of hard drive capacity needs to pay attention to what issues
Win7 upgrade 64-bit excel2003 can not open several solutions
The Windows 7 taskbar cannot display the power icon resolution
Win7 set vpn method diagram detailed tutorial
Win10 10547 preview version of the new call record and mail access permissions set
Find the difference between find, locate, whereis, which, type in linux