|
发表于 2008-2-3 14:31:16
|
显示全部楼层
用cron调用这个脚本试试,我菜鸟,所以写的很粗糙。嘿嘿~
crontab项
*/1 * * * * /path/to/reboot100.sh
$ cat reboot100.sh
#! /bin/bash
#
# reboot100.sh:
# cron will invoke this script in every minute.
#
remain=100
reboot100log="./reboot100.log"
[ $remain -eq 0 ] && {
crontab -r
echo "-----------------------------" >>$reboot100log
echo "done" >>$reboot100log
}
xpid=`ps -C 'Xorg' -o pid=`
if [ -n $xpid ]; then
r=`sed -n -e 's/remain=\([0-9].*\)/\1/p' $0`
((c=r-1))
sed -e "s/remain=\([0-9].*\)/remain=$c/" $0 >$0.$$
mv $0{.$$,}
now=`date "+%m-%d-%Y %H:%M:%S"`
echo "reboot $now" >>$reboot100log
sync; sync; init 3
fi
自己改吧。
方法应该多吧? |
|