linux添加开机启动项

LUOPING0 2011-06-12

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:

看下/etc/local.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.

相关推荐