CentOS 7.1では、即時再起動時にシャットダウン初期化スクリプトは実行されません。

CentOS 7.1では、即時再起動時にシャットダウン初期化スクリプトは実行されません。

以下を使用して、システムのシャットダウン時に実行できる初期化スクリプトをインストールしました。

/sbin/chkconfig --add shutdownExample

私のshutdownExample(システムのシャットダウン時に実行されるカスタムスクリプト)は次のとおりです。

#!/bin/bash
# chkconfig: 35 99 01
# description: custom shutdown script
# lockfile: /var/lock/subsys/shutdownExample

start() {
    # touch /var/lock/subsys/filename
    touch /var/lock/subsys/shutdownExample
 }

stop() {

    echo "Commands executed successfully at " >> shutdown.txt

    #some important stuff goes here

    rm -rf /var/lock/subsys/shutdownExample
}

case "$1" in
start)
start
;;
stop)
stop
;;

*)
echo $"Usage: $0 {start|stop}"
RETVAL=1
esac

exit 0

私の必要性は、shutdownExampleシステムがシャットダウンしたときにスクリプトを実行することです。ファイルを生成する必要がありますshutdown.txt

問題は、デーモンがインストールされた後にシステムを一度シャットダウンすると、K **スクリプトがパラメータをstop受け取らないことです。 2回目の再起動以降、initスクリプトは正常に実行されます。shutdownExample即時再起動時に鉱山が実行されないのはなぜですか?助けてくれてありがとう。

ベストアンサー1

おすすめ記事