[Menai-LUG] Auto startup task
Martin Sapsed
m.sapsed at bangor.ac.uk
Tue May 20 10:01:01 2003
David Goadby wrote:
> My SuSE system uses the usual sequence of init.d scripts which I never
> tinker with. Now, where is the best place to place my startup? The task
> really starts and runs for ever there are no special stop commands other
> than using kill on it. I suppose I could catch signals if that helps it
> conform with the init scripts options.
>
> I really don't want a lot of hassles just a plain simple run of
> capture_init.sh. Any ideas?
What I would do is find a small/simple existing script in init.d and
copy & modify it to run your script with the start argument and do
nothing with the stop one. On my Debian box the ntpdate init.d script is
pretty simple - I've pasted it in below.
Then in order for it to be executed you need a file in
rc<default-run-level>.d. If you don't know the default run level it
should be in /etc/inittab. cd into rc3.d (or whichever is appropriate)
and do something line
ln -s ../init.d/capture S99capture
if capture were the name of the script you'd created. on the link, the S
means it's a start script so it's executed when the system goes into
that runlevel. (The ones starting with K are run when you go out of that
level, like when you shutdown). The number indicates the order in which
to run the scripts - 99 implies do it after everything else just in case
it needs something else to be running already. Oh, make sure the init.d
script has execute permission.
Cheers,
Martin
#! /bin/sh
# /etc/init.d/ntpdate stolen from a Debian system!
PATH=/sbin:/bin
test -f /usr/sbin/ntpdate || exit 0
test -f /etc/default/ntp-servers || exit 0
. /etc/default/ntp-servers
test -n "$NTPSERVERS" || exit 0
case "$1" in
start|restart|force-reload)
echo -n "Running ntpdate to synchronize clock"
/usr/sbin/ntpdate -u -b -s $NTPSERVERS
echo "."
;;
stop)
;;
*)
echo "Usage: /etc/init.d/ntpdate {start|stop|restart|force-reload}"
exit 1
esac
exit 0
--
Martin Sapsed
Information Services "Who do you say I am?"
University of Wales, Bangor Jesus of Nazareth