シェルスクリプトを起動時に実行したい!
久々ためになった話をします。
vi /etc/rc.d/rc.local (もしくは vi /etc/rc.local)
でvimより実行したいシェルのパスを記述します。
ちなみに血まみれサーバ(Ubuntu 11.10)のrc.localの中身はこんな感じ。↓
xxx@xxx:~$ vi /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0
この中に「ifconfigの実行結果をメールで送る(サーバのIPを知らせたい。*1そのうち書くかも?)」て内容を書いたけど、rootコマンドもしっかり動いたの確認できました!べんり。