v-suspend-cron-job 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 defenition
  10. user=$1
  11. job=$2
  12. restart=$3
  13. # Inlcudes
  14. source $VESTA/func/main.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'USER JOB [RESTART]'
  20. validate_format '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. # Restart crond
  36. if [ "$restart" != 'no' ]; then
  37. $BIN/v-restart-cron
  38. if [ $? -ne 0 ]; then
  39. exit E_RESTART
  40. fi
  41. fi
  42. # Logging
  43. log_event "$OK" "$EVENT"
  44. exit