Commands for normal shutdown in linux

Source: Internet
Author: User
This section describes how to determine the normal shutdown problem. I have collected some information for you to view and hope you can get help. When the system starts, a file is generated. when the system shuts down normally, the file is deleted. Network administrators can determine whether the system is shut down abnormally based on the file that is not used when the system is started. here we will introduce the problem of normal shutdown. I have collected some information for you to view and hope you can get help.

When the system starts, a file is generated. when the system shuts down normally, the file is deleted. Network administrators can determine whether the system is shut down abnormally based on the file that is not used when the system is started, reducing the chance of failure during network management.

Steps:

Program the script in/etc/rc. d/init. d.

Determine whether the shutdown is normal, and generate a file script: 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

Linux normal shutdown delete file script: rm-file.sh

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

>/Var/log/checkmessage rm-rf $

Make the script run 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 can be an absolute or relative path, and the names of the two sides must be 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 does not use x-window, so there is no level5, that is, there is no need to place scripts in/etc/rc. d/rc5.d.

Note:

Start with K indicates that the system is shut down, and start with S indicates that the system is executed at startup. Pay attention to the specification of script writing, because the soft link opened by K may not be automatically executed during shutdown. why? When you execute the K script, it will query whether there is an empty file name with the same name as the script starting with K in/var/lock/subsys/. if not, it will not be executed. Therefore, follow the script writing specifications, when starting, touch an empty file with the same name as K01 at/var/lock/subsys:

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

The above explains how to determine the normal shutdown problem in linux.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.