手机版
你好,游客 登录 注册
背景:
阅读新闻

Update-rc.d && rc.local管理Ubuntu的开机启动

[日期:2013-01-10] 来源:Linux社区  作者:zinss [字体:大 中 小]

Option -f Force removal of symlinks even if /etc/init.d/name still exists.(相当于就算/etc/init.d/下还存在apache脚本,但是/etc/rcX.d/下所有关于apache2的软链接均被删除)

Adding A Service

Default Priorities

Now, if you want to re-add your service to be started on boot up, you can simply use:

Specifying Custom Runlevels

Finally, if you want to Start and Kill on Specific runlevels, like for instances starting writelog with priority 90 on runlevels 2, 3, 4, 5 and kill with priority 91 on runlevels 0, 1 and 6, you can follows this operation:

我的一个init.d启动脚本样例

wangzhengyi@cloud-1:/etc/init.d$ cat writelog
#!/bin/sh

### BEGIN INIT INFO
# Provides:          wzy
# Required-Start:    $remote_fs $syslog
# Required-Stop:    $remote_fs $syslog
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: test update-rc.d to start a service
### END INIT INF

PATH="/sbin:/usr/sbin:/bin:/usr/bin"
DESC="write log daemon"
SCRIPTNAME="/home/wangzhengyi/scripts/ceshi.sh"


export PATH=$PATH

. /lib/lsb/init-functions

do_start() {
 log_begin_msg "Runing wzy writeing log scripts $SCRIPTNAME"
 if [ -x $SCRIPTNAME ]; then
  $SCRIPTNAME
  ES=$?
 fi
 log_end_msg $ES
}

case "$1" in
 start)
  do_start
  ;;
 restart|reload|force-reload|staus)
  echo "Error: argument '$1' not supported" >&2
        exit 3
  ;;
 stop)
  ;;
 *)
         echo "Usage: $0 start|stop" >&2
         exit 3
         ;;
esac

 
exit 0

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款