]>
Commit | Line | Data |
---|---|---|
9088c091 AM |
1 | #!/bin/sh |
2 | # | |
3 | # crond Start/Stop the cron clock daemon. | |
4 | # | |
5 | # chkconfig: 2345 40 60 | |
6 | # description: cron is a standard UNIX program that runs user-specified \ | |
7 | # programs at periodic scheduled times. cronie adds a \ | |
8 | # number of features to the basic UNIX cron, including better \ | |
9 | # security and more powerful configuration options. | |
10 | # | |
11 | # processname: crond | |
ae05e276 | 12 | # config: /etc/cron.d |
9088c091 AM |
13 | # pidfile: /var/run/crond.pid |
14 | ||
15 | ||
16 | # Source function library. | |
17 | . /etc/rc.d/init.d/functions | |
18 | ||
eb28333d ER |
19 | CROND_ARGS="" |
20 | ||
9088c091 AM |
21 | # Get service config |
22 | [ -f /etc/sysconfig/cron ] && . /etc/sysconfig/cron | |
23 | ||
24 | start() { | |
25 | # Check if the service is already running? | |
ee7fe710 ER |
26 | if [ -f /var/lock/subsys/crond ]; then |
27 | msg_already_running "cronie crond" | |
28 | return | |
9088c091 | 29 | fi |
ee7fe710 | 30 | |
eb28333d ER |
31 | if is_yes "$CROND_SYSLOG_RESULT"; then |
32 | CROND_ARGS="$CROND_ARGS -s" | |
33 | fi | |
34 | ||
35 | if [ -n "$CROND_MAIL_PROG" ]; then | |
36 | # XXX: should we handle spaces in $CROND_MAIL_PROG? | |
37 | CROND_ARGS="$CROND_ARGS -m $CROND_MAIL_PROG" | |
38 | fi | |
39 | ||
ee7fe710 | 40 | msg_starting "cronie crond" |
eb28333d | 41 | daemon /usr/sbin/crond $CROND_ARGS |
ee7fe710 ER |
42 | RETVAL=$? |
43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/crond | |
9088c091 AM |
44 | } |
45 | ||
46 | stop() { | |
ee7fe710 ER |
47 | if [ ! -f /var/lock/subsys/crond ]; then |
48 | msg_not_running "cronie crond" | |
49 | return | |
9088c091 | 50 | fi |
ee7fe710 ER |
51 | |
52 | msg_stopping "cronie crond" | |
53 | killproc crond | |
54 | rm -f /var/lock/subsys/crond | |
55 | } | |
56 | ||
57 | reload() { | |
58 | if [ ! -f /var/lock/subsys/crond ]; then | |
59 | msg_not_running "cronie crond" | |
60 | RETVAL=7 | |
61 | return | |
62 | fi | |
63 | ||
64 | msg_reloading "cronie crond" | |
65 | killproc crond -HUP | |
66 | RETVAL=$? | |
67 | } | |
68 | ||
69 | condrestart() { | |
70 | if [ ! -f /var/lock/subsys/crond ]; then | |
71 | msg_not_running "cronie crond" | |
72 | RETVAL=$1 | |
73 | return | |
74 | fi | |
75 | ||
76 | stop | |
77 | start | |
9088c091 AM |
78 | } |
79 | ||
bb090c53 JK |
80 | upstart_controlled |
81 | ||
9088c091 AM |
82 | RETVAL=0 |
83 | # See how we were called. | |
84 | case "$1" in | |
85 | start) | |
86 | start | |
87 | ;; | |
88 | stop) | |
89 | stop | |
90 | ;; | |
9088c091 AM |
91 | restart) |
92 | stop | |
93 | start | |
94 | ;; | |
ee7fe710 ER |
95 | try-restart) |
96 | condrestart 0 | |
97 | ;; | |
17ffa6b5 | 98 | reload|force-reload|flush-logs) |
ee7fe710 ER |
99 | reload |
100 | ;; | |
101 | status) | |
02a3c1b6 | 102 | status --pidfile /var/run/crond.pid crond |
ee7fe710 | 103 | exit $? |
9088c091 AM |
104 | ;; |
105 | *) | |
17ffa6b5 | 106 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}" |
9088c091 AM |
107 | exit 3 |
108 | esac | |
109 | ||
110 | exit $RETVAL |