页面

2011-09-13

adding script as booting service in debian

Say the script `foo.sh':
#! /bin/sh
# /etc/init.d/foo
#

# Some things that run always
touch /var/lock/foo

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting script foo ..."
    ;;
  stop)
    echo "Stopping script foo ..."
    ;;
  *)
    echo "Usage: /etc/init.d/foo {start|stop}"
    exit 1
    ;;
esac

exit 0
Then save it into `/etc/init.d' and give privilege:
$ chmod 755 /etc/init.d/foo
Add it to default runlevel:
$ update-rc.d foo defaults

没有评论: