[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Running something on start up and shutdown



> What's the best way to run a script once on startup and again (well, a
> related script) on shutdown?  I want to run the scripts as a user rather
> than root, which I believe is the standard init.d method.

your script could read:

#!/bin/sh
# /etc/init.d/myscript
# references /etc/init.d/mystartupscript
#            /etc/init.d/myhaltscript
case "$1" in
  start|restart)
    su <user> -c '/etc/init.d/mystartupscript'
    ;;
  stop)
    su <user> -c '/etc/init.d/myhaltscript'
    ;;
  *)
    echo "Usage: myscript start|stop|restart"
    ;;
esac
# The End.

just put it in init.d and use update-rc.d to make it run automatically
greetz,

Joris


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: