星期四, 4月 11, 2019

ubuntu init.d runlevel update-rc.d

Ubuntu startup script
http://felix-lin.com/linux/debianubuntu-%E6%96%B0%E5%A2%9E%E9%96%8B%E6%A9%9F%E8%87%AA%E5%8B%95%E5%9F%B7%E8%A1%8C%E7%A8%8B%E5%BC%8F/

/etc/init.d/blah
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/sh
# /etc/init.d/blah
#
 
# Some things that run always
touch /var/lock/blah
 
# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting script blah "
    echo "Could do more here"
    ;;
  stop)
    echo "Stopping script blah"
    echo "Could do more here"
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac
 
exit 0


update-rc.d blah defaults
update-rc.d blah start 20 2 3 4 . stop 80 0 1 6 .
start 20th in 2/3/4 runlevel
update-rc.d -f blah remove

沒有留言: