mysql_backup_stop.sh 781 B

1234567891011121314151617181920212223242526272829303132333435
  1. service="/sbin/service"
  2. # 检查cron服务状态
  3. cron_status=$(service cron status)
  4. if grep -q "unrecognized" <<< "$cron_status"
  5. then
  6. echo "cron未安装"
  7. elif grep -q "is not running" <<< "$cron_status"
  8. then
  9. echo "cron未启动"
  10. elif grep -q "is running" <<< "$cron_status"
  11. then
  12. echo "cron已启动"
  13. else
  14. echo "未知状态"
  15. fi
  16. CURRENT_DIR=$(cd "$(dirname "$0")";pwd)
  17. find_file="${CURRENT_DIR}/cron.conf"
  18. find_str="mysql_backup_run"
  19. crontab -l > ${find_file}
  20. # 检查记录中是否有mysql_backup_run条目数据
  21. if [ `grep -c "$find_str" ${find_file}` -ne '0' ]
  22. then
  23. echo "正在删除备份计划任务"
  24. sed -i "/$find_str/d" ${find_file}
  25. crontab ${find_file}
  26. else
  27. echo "不存在备份计划任务"
  28. fi
  29. cat ${find_file}
  30. rm -f ${find_file}