#!/bin/sh
# Startup script for myprog
#
prog="myprog"
XCLOCK=/usr/X11R6/bin/xclock
[ -f $XCLOCK ] || exit 0
start() {
echo -n $"Starting $prog: "
$XCLOCK -display
ponto:0.0 &
echo "Hello Patty"
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
kill `ps -ef | grep xclock | grep
-v grep | awk '{print $2}'`
echo "Goodbye Patty"
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit 0
Make your script executable:
# chmod +x myprogTest your script from /etc/rc.d/init.d:
# ./myprog startNow create symbolic links in /etc/rc.d/rc4.d to start your script
# ./myprog stop
# cd /etc/rc.d/rc4.dIn order to see your program's messages you must be able to view the console.
# ln -s ../init.d/myprog S99myprog
# tail -f /var/log/messagesDid you see your program get exectued when you changed run-levels?
Examine the /etc/inittab script and find the line which executes rc.sysinit.
Write it down:____________________________________________________
Explain each of the 4 fields.
To find the current and previous run-level:
# runlevelTo change to run-level 4:
# telinit 4
or
# init 4