v-suspend-cron-job 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: suspend cron job
  3. # options: USER JOB [RESTART]
  4. #
  5. # The function suspends a certain job of the cron scheduler.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. job=$2
  12. restart=$3
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'USER JOB [RESTART]'
  20. is_format_valid 'user' 'job'
  21. is_object_valid 'user' 'USER' "$user"
  22. is_object_valid 'cron' 'JOB' "$job"
  23. is_object_unsuspended 'cron' 'JOB' "$job"
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Suspending job
  28. update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes'
  29. increase_user_value "$user" '$SUSPENDED_CRON'
  30. # Sync system cron with user
  31. sync_cron_jobs
  32. #----------------------------------------------------------#
  33. # Vesta #
  34. #----------------------------------------------------------#
  35. # Restarting crond
  36. if [ "$restart" != 'no' ]; then
  37. $BIN/v-restart-cron
  38. check_result $? "Cron restart failed" >/dev/null
  39. fi
  40. # Logging
  41. log_event "$OK" "$ARGUMENTS"
  42. exit