1234567891011121314151617181920212223242526272829303132333435 |
- 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 "正在删除备份计划任务"
- sed -i "/$find_str/d" ${find_file}
- crontab ${find_file}
- else
- echo "不存在备份计划任务"
- fi
- cat ${find_file}
- rm -f ${find_file}
|