Reboot UNIXPC from via cron

Prentiss Riddle riddle at woton.UUCP
Thu May 26 02:09:38 AEST 1988


> Could you provide a method for be-booting a UNIX PC via a crontab entry or
> some other means?

Here's what we use.  Suggestions or improvements welcome.
-----------------------------------------------------------------------------
#	niteboot.sh -- shell script to gracefully reboot the system
#
#  This should be run nightly from /usr/lib/crontab, e.g.:
#
#	1 4 * * * /usr/bin/niteboot
#
#  A nightly reboot seems to be necessary on the UNIX PC in order to
#  clear out bogus utmp entries, hung communications processes, messed-up
#  inittab lines, etc.
#
#  We use this instead of /etc/shutdown because /etc/shutdown puts messages
#  in windows on the console and requires confirmation from a user; we use
#  it in place of straight /etc/reboot because we want to do some syncs and
#  issue a few warnings first.
#
#  Bugs: /etc/wall seems to be unreliable on the UNIX PC -- even with "mesg y"
#  turned on, users don't seem to always get the message.  Sigh.
#
#  History:
#  87.11.10  riddle	Original version.
#  87.11.19  riddle	Fixed "/etc/sleep" bug.
#
cd /
echo "
	\003System rebooting in 10 minutes -- log out now!

	\003System rebooting in 10 minutes -- log out now!

	\003System rebooting in 10 minutes -- log out now!

	\003System rebooting in 10 minutes -- log out now!

	\003System rebooting in 10 minutes -- log out now!
" | /etc/wall
sleep 540
cd /
/usr/lib/lpshut > /dev/null 2> /dev/null
echo "
	\003System rebooting in 1 minute -- log out now!

	\003System rebooting in 1 minute -- log out now!

	\003System rebooting in 1 minute -- log out now!

	\003System rebooting in 1 minute -- log out now!

	\003System rebooting in 1 minute -- log out now!
" | /etc/wall
sync;sync
sleep 60
#
sync;sync
/etc/reboot
-----------------------------------------------------------------------------
-- Prentiss Riddle ("Aprendiz de todo, maestro de nada.")
-- Opinions expressed are not necessarily those of my employer.
-- riddle%woton.uucp at cs.utexas.edu  uunet!ut-sally!cs.utexas.edu!woton!riddle



More information about the Comp.sys.att mailing list