mysql_backup_status.sh 714 B

123456789101112131415161718192021222324252627282930313233
  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. else
  25. echo "不存在备份计划任务"
  26. fi
  27. cat ${find_file}
  28. rm -f ${find_file}