Aria2c经常崩溃,所以使用一个脚本每秒检测Aria2c是否运行,如果没有,则延时10秒重启Aria2c.

#!/bin/bash
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`  
result=$(echo $ps_out | grep "$1")  
if [[ "$result" != "" ]];then  
    echo "Service Running"
else  
    echo "Serivce Not Running"
fi  

检测Aria2c:

$./check.sh aria2c

自动检测重启Aria2c:

#!/bin/bash
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`  
result=$(echo $ps_out | grep "$1")  
if [[ "$result" != "" ]];then  
    echo "Aria2c Running"
else  
    /usr/bin/aria2c --conf-path="/root/.aria2/aria2.conf" -D
fi  

添加到crontab:

# m h  dom mon dow   command
* * * * * sleep 10; /usr/bin/check aria2c