Good Morning,
I have made a script to log the computer startup and shutdown (shutdown).
I am interested in modifying this script so that when I do a manual reboot or halt it will also register.
In this way I know when it is restarted by a manual reboot, by a power failure, by a shutdown or by a halt.
That is, when I shutdown it works for me, but when I do reboot or halt, it doesn't. how could i do this?
This is my script:
Thanks for the help.
I have made a script to log the computer startup and shutdown (shutdown).
I am interested in modifying this script so that when I do a manual reboot or halt it will also register.
In this way I know when it is restarted by a manual reboot, by a power failure, by a shutdown or by a halt.
That is, when I shutdown it works for me, but when I do reboot or halt, it doesn't. how could i do this?
This is my script:
Code:
#!/bin/sh
# PROVIDE: rmiregistry
# BEFORE: LOGIN
# KEYWORD: shutdown
# Añadir a /etc/rc.conf xxxxx_enable="YES"
. /etc/rc.subr
#rmiregistry_enable=${rmiregistry:-"NO"}
name=rmiregistry
rcvar=`set_rcvar`
pidfile="/var/run/${name}.pid"
start_cmd="start"
stop_cmd="stop"
restart_cmd="restart"
describe_cmd="describe"
load_rc_config $name
start() {
if [ ! -f $pidfile ] ; then
echo -e "Starting services: $pidfile"
echo $$ > $pidfile
find /usr/local/etc/rc.d/server.log -type f -size 1M -exec rm '>
date +'Start server: %F %T'>>/usr/local/etc/rc.d/server.log;
#echo -e "rmiregistry is now running on $pidfile"
#rmiregistry &
#echo $! > $pidfile
#echo "."
else
echo "It appears $pidfile is already running. NOT starting!"
fi
}
stop() {
if [ ! -f $pidfile ] ; then
echo -e "It appears $pidfile is not running."
else
echo -e "Stopping services: $pidfile"
date +'Stop server: %F %T'>>/usr/local/etc/rc.d/server.log;
kill `cat $pidfile`
rm $pidfile
fi
}
restart() {
stop;
start;
}
describe(){
echo "Escribe en log el inicio y apagado"
}
run_rc_command "$1"
Thanks for the help.