Fedora 15/16は終了時に自動的にスクリプトを実行します。

Fedora 15/16は終了時に自動的にスクリプトを実行します。

Fedora 15または16では、シャットダウン時にシェルスクリプトを自動的に実行するディレクトリが見つかりません。

ベストアンサー1

/etc/rc.dFedora 16は、起動時と終了時にスクリプトを実行できる従来の「System V」スタイルの初期化スクリプトを置き換えました。システム。システムを作成できます提供する従来のinitスクリプトと同様に、起動と停止時にシェルスクリプトを実行するファイルです。次のように入力してください/lib/systemd/system/runonshutdown.service

[Service]
Type=forking
ExecStart=/path/to/myscript start
ExecStop=/path/to/myscript stop
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

これを完了したら、次のことを実行できます。

# chkconfig runonshutdown on
ln -s '/lib/systemd/system/runonshutdown.service' '/etc/systemd/system/multi-user.target.wants/runonshutdown.service'

これはシステムの起動時に実行され、/path/to/myscript startシステムのシャットダウン時に実行されます/path/to/myscript stop

詳しくはsystemd.service(5)マニュアルページをご覧ください。

おすすめ記事