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