Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the normal shutdown commands under linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what are the normal shutdown commands under linux, which can be used for reference by interested friends. I hope you will gain a lot after reading this article.

A file is generated when the system starts and will be deleted when linux shuts down normally. On the other hand, network administrators can judge whether there is an abnormal shutdown according to whether there is that file when the system is started, so as to reduce the probability of failure in the process of network management.

Steps:

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

Determine whether the computer shuts down properly, 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 for normal shutdown and deletion of files under linux: 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 on both sides of the soft connection are not the same, and the latter can use an absolute path or a relative path. Make sure that the names on both sides are 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 I don't have level5, which means I don't have to delegate scripts to / etc/rc.d/rc5.d/.

Pay special attention to:

K represents execution when the system is shut down, and S represents boot time. Pay attention to the specification of server scripting, because soft links with K are not necessarily executed automatically when shutting down. Why? When executing the K script, it will query whether there is an empty file name under / var/lock/subsys/ with the same name as the script at the beginning of K. If not, it will not be executed. Therefore, according to the specification written by the server script, touch an empty file with the same name as K01 after / var/lock/subsys/ when starting:

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

Thank you for reading this article carefully. I hope the article "what are the normal shutdown orders under linux" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report