cronie.init 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/sh
  2. #
  3. # crond Start/Stop the cron clock daemon.
  4. #
  5. # chkconfig: 2345 90 60
  6. # description: cron is a standard UNIX program that runs user-specified \
  7. # programs at periodic scheduled times. vixie cron adds a \
  8. # number of features to the basic UNIX cron, including better \
  9. # security and more powerful configuration options.
  10. ### BEGIN INIT INFO
  11. # Provides: crond crontab
  12. # Required-Start: $local_fs $syslog
  13. # Required-Stop: $local_fs $syslog
  14. # Default-Start: 2345
  15. # Default-Stop: 90
  16. # Short-Description: run cron daemon
  17. # Description: cron is a standard UNIX program that runs user-specified
  18. # programs at periodic scheduled times. vixie cron adds a
  19. # number of features to the basic UNIX cron, including better
  20. # security and more powerful configuration options.
  21. ### END INIT INFO
  22. [ -f /etc/sysconfig/crond ] || {
  23. [ "$1" = "status" ] && exit 4 || exit 6
  24. }
  25. RETVAL=0
  26. prog="crond"
  27. exec=/usr/sbin/crond
  28. lockfile=/var/lock/subsys/crond
  29. config=/etc/sysconfig/crond
  30. # Source function library.
  31. . /etc/rc.d/init.d/functions
  32. [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
  33. start() {
  34. if [ $UID -ne 0 ] ; then
  35. echo "User has insufficient privilege."
  36. exit 4
  37. fi
  38. [ -x $exec ] || exit 5
  39. [ -f $config ] || exit 6
  40. echo -n $"Starting $prog: "
  41. daemon $prog $CRONDARGS
  42. retval=$?
  43. echo
  44. [ $retval -eq 0 ] && touch $lockfile
  45. }
  46. stop() {
  47. if [ $UID -ne 0 ] ; then
  48. echo "User has insufficient privilege."
  49. exit 4
  50. fi
  51. echo -n $"Stopping $prog: "
  52. if [ -n "`pidfileofproc $exec`" ]; then
  53. killproc $exec
  54. RETVAL=3
  55. else
  56. failure $"Stopping $prog"
  57. fi
  58. retval=$?
  59. echo
  60. [ $retval -eq 0 ] && rm -f $lockfile
  61. }
  62. restart() {
  63. stop
  64. start
  65. }
  66. reload() {
  67. echo -n $"Reloading $prog: "
  68. if [ -n "`pidfileofproc $exec`" ]; then
  69. killproc $exec -HUP
  70. else
  71. failure $"Reloading $prog"
  72. fi
  73. retval=$?
  74. echo
  75. }
  76. force_reload() {
  77. # new configuration takes effect after restart
  78. restart
  79. }
  80. rh_status() {
  81. # run checks to determine if the service is running or use generic status
  82. status -p /var/run/crond.pid $prog
  83. }
  84. rh_status_q() {
  85. rh_status >/dev/null 2>&1
  86. }
  87. case "$1" in
  88. start)
  89. rh_status_q && exit 0
  90. $1
  91. ;;
  92. stop)
  93. rh_status_q || exit 0
  94. $1
  95. ;;
  96. restart)
  97. $1
  98. ;;
  99. reload)
  100. rh_status_q || exit 7
  101. $1
  102. ;;
  103. force-reload)
  104. force_reload
  105. ;;
  106. status)
  107. rh_status
  108. ;;
  109. condrestart|try-restart)
  110. rh_status_q || exit 0
  111. restart
  112. ;;
  113. *)
  114. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  115. exit 2
  116. esac
  117. exit $?