linux除了crontab之外有没有每隔x分钟自动运行的命令
发布时间:2010-07-11 18:24:31来源:红联作者:dchwlinux
[i=s] 本帖最后由 dchwlinux 于 2010-7-11 18:26 编辑 [/i]
我在ubuntu里wine迅雷,运行还可以,就是老崩溃。还好能断点续传。于是我就设置启动后自动开始下载,然后想方没法让迅雷一直运行。最初用的是crontab工具,可是发现不方便,不太灵活。于是我就想写个shell。跌跌撞撞地摸索,最后勉强利用read -t的等待功能实现每隔1分钟检测迅雷是否崩溃,我就想问下还有没有别的法子能随时地检测迅雷是否崩溃,或者对我的shell提出改进建议。[code]#!/bin/bash
########该文件是为了使迅雷崩溃后能够重启,以便能持续下载直到下载完成。######
clear
t=0
time=`date|awk '{print $5}'`
echo -e "\t\t\t\t现在是$time,迅雷开始运行\n"
while [ "$i" != "0" ]
do
name=`/bin/ps aux|grep Thunder|grep Pro|awk '{print $1}'`
if [ "$name" != "`whoami`" ];then
~/Thunder.sh >/dev/null 2>&1 & #~/Thunder.sh是wine启动迅雷的脚本
if [ $t != 0 ];then
echo -e "迅雷在`date|awk '{print $5}'`时崩溃了一次。"|tee -a /home/davids/crash_thunder.txt
fi
fi
echo -e "\n\t\t\t\t已经下载了$t分钟了。"
echo -e "\t\t\t\t请在输入0之后再关闭迅雷:"
t=$(($t+1))
read -t 60 -p "`echo -e '\t\t\t\t'`" i
done
echo -e "\t\t\t\t现在是`date|awk '{print $5}'`,\n\t\t\t\t迅雷于$time开始。\n\n\n\t\t\t\t**可以关闭迅雷了。** :)\n\n\n"[/code]