以前写的玩的,Ubuntu下用的.不想改了~ 在FreeBSD 下要改下~可以拿来做实验~
当然这个有很大问题的。
最好加参数好让它停下来
#!/bin/bash
#
#Do auto reboot after Log on and show the reboot time
#Usage: Add /etc/rc.local   bash autoreboot.sh 
#Ver:0.1  2007/11/05 by ****
#***************************************************************************** 
if [ ! -x "/home/count.txt" ];then
echo "0" > /home/count.txt
chmod +x /home/count.txt
fi
  n=`cat /home/count.txt | awk '{print substr($1,1)}'`
  let "n++"
  echo "$n" > /home/count.txt
  echo "Times=$n ,Start to do reboot at `date`" >> /home/reboot_log.txt
  echo "It will reboot in 2 minutes!You can command shutdown -c by root to stop it!!" >> /home/reboot_log.txt
# gedit /home/reboot_log.txt
  shutdown -r -time 2 "It will reboot in 2 minutes!You can command shutdown -c by root to stop it!" 

顺便 在/usr/local/etc/rc.d 中一个普通的启动脚本是这样的
#!/bin/sh
echo -n ' FooBar'
case "$1" in
start)
/usr/local/bin/foobar
;;
stop)
kill -9 'cat /var/run/foobar.pid'
;;
*)
echo "Usage: 'basename $0' {start|stop}" >&2
exit 64
;;
esac
exit 0