linux 编写定时任务,查询服务是否挂掉

shell 脚本

#!/bin/bash

a=`netstat -unltp|grep fdfs|wc -l`

echo "$a"
if [ "$a" -ne "1" ];then
    `fdfs_storaged /etc/fdfs/storage.conf start`
fi

 用 crontab 设定定时任务

crontab -e,一分钟执行一次脚本
* * * * * sh /home/fr/test.sh

 查看 crontab 日志

 tailf var/log/cron

  

原文地址:https://www.cnblogs.com/royfans/p/12018434.html