1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  | 
#!/bin/bash
# chkconfig: 345 91 9                # runlevel 345で起動 起動時にはS91で、終了時にはK09で
# description: exampled.             # chkconfig 的にないといかん
prog="exampled"
# 停止スクリプト実行時に必要
# 実質利用するのは /etc/rc.d/rc0.d/S00killall
lockfile=/var/lock/subsys/${prog}
. /etc/rc.d/init.d/functions
start()
{
  echo -e "$(date)\tStart" >> /tmp/result.log
  retval=$?
  [ ${retval} -eq 0 ] && touch ${lockfile}
}
stop()
{
  echo -e "$(date)\tStop" >> /tmp/result.log
  retval=$?
  [ ${retval} -eq 0 ] && rm -f ${lockfile}
}
status()
{
  status ${prog}
}
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  *)
    echo $"Usage: $0 {start|stop|status}"
    [ "x$1" = "x" ] && exit 0
    exit 2
esac
exit $?
  |