123456789101112131415161718192021222324252627282930313233 |
- service="/sbin/service"
- # 检查cron服务状态
- cron_status=$(service cron status)
- if grep -q "unrecognized" <<< "$cron_status"
- then
- echo "cron未安装"
- elif grep -q "is not running" <<< "$cron_status"
- then
- echo "cron未启动"
- elif grep -q "is running" <<< "$cron_status"
- then
- echo "cron已启动"
- else
- echo "未知状态"
- fi
- CURRENT_DIR=$(cd "$(dirname "$0")";pwd)
- find_file="${CURRENT_DIR}/cron.conf"
- find_str="mysql_backup_run"
- crontab -l > ${find_file}
- # 检查记录中是否有mysql_backup_run条目数据
- if [ `grep -c "$find_str" ${find_file}` -ne '0' ]
- then
- echo "已存在备份计划任务"
- else
- echo "不存在备份计划任务"
- fi
- cat ${find_file}
- rm -f ${find_file}
|