Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

02.AutoBackup_crontab_check.sh 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. Service1=/ED/Gitea_ED/Script_Gitea_ED/Gitea_EDbackup-mysql-Auto.sh
  3. Service2=/ED/Gitea_ED/Script_Gitea_ED/Gitea_EDbackup-Script_Gitea_ED-Auto.sh
  4. Service3=/ED/Gitea_ED/Script_Gitea_ED/Gitea_EDbackup-Source_Files-Auto.sh
  5. Service4=/ED/Gitea_ED/Script_Gitea_ED/Gitea_EDRemote_backup.sh
  6. Service5=/ED/Gitea_ED/Script_Gitea_ED/Gitea_EDbackup-INI.sh
  7. WHO=`whoami`
  8. crontab -u $WHO -l
  9. echo
  10. crontab -u $WHO -l | grep "$Service1" > /dev/null 2>&1
  11. if [[ $? == 0 ]]; then
  12. crontab -u $WHO -l | grep "$Service1" | cut -c 1-8 | grep "#"
  13. if [[ $? != 0 ]]; then
  14. echo -e "\033[33mPass. $Service1 was set active. \033[0m"
  15. else
  16. echo -e "\033[45;37mWarning! $Service1 was appended, but not be set as executing. \033[0m"
  17. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  18. echo -e "\033[33m#// Create backup file every 2 days at 01:08\033[0m"
  19. echo -e "\033[33m8 1 */2 * * $Service1\033[0m"
  20. fi
  21. else
  22. echo -e "\033[41;37mFail. $Service1 was not be set as executing. \033[0m"
  23. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  24. echo -e "\033[33m#// Create backup file every 2 days at 01:08\033[0m"
  25. echo -e "\033[33m8 1 */2 * * $Service1\033[0m"
  26. fi
  27. echo
  28. crontab -u $WHO -l | grep "$Service2" > /dev/null 2>&1
  29. if [[ $? == 0 ]]; then
  30. crontab -u $WHO -l | grep "$Service2" | cut -c 1-8 | grep "#"
  31. if [[ $? != 0 ]]; then
  32. echo -e "\033[33mPass. $Service2 was set active. \033[0m"
  33. else
  34. echo -e "\033[45;37mWarning! $Service2 was appended, but not be set as executing. \033[0m"
  35. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  36. echo -e "\033[33m#// Create backup file every first day of month at 01:06"
  37. echo -e "\033[33m6 1 1 * * $Service2\033[0m"
  38. fi
  39. else
  40. echo -e "\033[41;37mFail. $Service2 was not be set as executing. \033[0m"
  41. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  42. echo -e "\033[33m#// Create backup file every first day of month at 01:06"
  43. echo -e "\033[33m6 1 1 * * $Service2\033[0m"
  44. fi
  45. echo
  46. crontab -u $WHO -l | grep "$Service3" > /dev/null 2>&1
  47. if [[ $? == 0 ]]; then
  48. crontab -u $WHO -l | grep "$Service3" | cut -c 1-8 | grep "#"
  49. if [[ $? != 0 ]]; then
  50. echo -e "\033[33mPass. $Service3 was set active. \033[0m"
  51. else
  52. echo -e "\033[45;37mWarning! $Service3 was appended, but not be set as executing. \033[0m"
  53. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  54. echo -e "\033[33m#// Create backup file every first day of month at 01:00"
  55. echo -e "\033[33m0 1 1 * * $Service3\033[0m"
  56. fi
  57. else
  58. echo -e "\033[41;37mFail. $Service3 was not be set as executing. \033[0m"
  59. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  60. echo -e "\033[33m#// Create backup file every first day of month at 01:00"
  61. echo -e "\033[33m0 1 1 * * $Service3\033[0m"
  62. fi
  63. echo
  64. crontab -u $WHO -l | grep "$Service4" > /dev/null 2>&1
  65. if [[ $? == 0 ]]; then
  66. crontab -u $WHO -l | grep "$Service4" | cut -c 1-8 | grep "#" > /dev/null 2>&1
  67. if [[ $? != 0 ]]; then
  68. echo -e "\033[33mPass. $Service4 was set active. \033[0m"
  69. else
  70. echo -e "\033[45;37mWarning! $Service4 was appended, but not be set as executing. \033[0m"
  71. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  72. echo -e "\033[33m#// Create backup file every Monday 06:00"
  73. echo -e "\033[33m0 6 * * 1 $Service4\033[0m"
  74. fi
  75. else
  76. echo -e "\033[41;37mFail. $Service4 was not be set as executing. \033[0m"
  77. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  78. echo -e "\033[33m#// Create backup file every Monday 06:00"
  79. echo -e "\033[33m0 6 * * 1 $Service4\033[0m"
  80. fi
  81. echo
  82. crontab -u $WHO -l | grep "$Service5" > /dev/null 2>&1
  83. if [[ $? == 0 ]]; then
  84. crontab -u $WHO -l | grep "$Service5" | cut -c 1-8 | grep "#" > /dev/null 2>&1
  85. if [[ $? != 0 ]]; then
  86. echo -e "\033[33mPass. $Service5 was set active. \033[0m"
  87. else
  88. echo -e "\033[45;37mWarning! $Service5 was appended, but not be set as executing. \033[0m"
  89. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  90. echo -e "\033[33m#// Create backup file every first day of month at 03:20"
  91. echo -e "\033[33m20 3 1 * * $Service5\033[0m"
  92. fi
  93. else
  94. echo -e "\033[41;37mFail. $Service5 was not be set as executing. \033[0m"
  95. echo -e "Please add below info by command \033[32m\"crontab -u $WHO -e\"\033[0m"
  96. echo -e "\033[33m#// Create backup file every first day of month at 03:20"
  97. echo -e "\033[33m20 3 1 * * $Service5\033[0m"
  98. fi
  99. echo
  100. echo