linux起動項目の追加

1060 ワード

ubuntu:
1.スクリプトxxxを/etc/initに配置する.d/下
2.スクリプト実行権限の変更:chmod 755 xxx
3.update-rc.d xxx defaults NN(NNは起動順序)は、システム起動実行のキューにスクリプトを追加します.
 
centos:
1.chkconfig形式のスクリプトxxxを作成し、/etc/initに置く.d/下:
 
#/bin/sh
#chkconfig: 2345 20 80  
#description: nginx script,2345    20        80       
case $1 in
          start)  /usr/bin/nginx             ;;
          stop)   /usr/bin/nginx -s quit     ;;
              *)  echo "require start|stop"  ;;
esac


2.スクリプト実行権限の変更:chmod 755 xxx
3.サービスの追加:chkconfig--add xxx
 
gentoo:
見てみろd/READMEという書類は、はっきりと書かれています
This directory should contain programs or scripts which are to be run
when the local service is started or stopped.
 
If a file in this directory is executable and it has a .start extension,
it will be run when the local service is started. If a file is
executable and it has a .stop extension, it will be run when the local
service is stopped.
 
All files are processed in lexical order.