]> git.pld-linux.org Git - packages/cronie.git/blob - cronie.init
- up to 1.5.0
[packages/cronie.git] / cronie.init
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
12 # config:       /etc/cron.d
13 # pidfile:      /var/run/crond.pid
14
15
16 # Source function library.
17 . /etc/rc.d/init.d/functions
18
19 CROND_ARGS=""
20
21 # Get service config
22 [ -f /etc/sysconfig/cron ] && . /etc/sysconfig/cron
23
24 start() {
25         # Check if the service is already running?
26         if [ -f /var/lock/subsys/crond ]; then
27                 msg_already_running "cronie crond"
28                 return
29         fi
30
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
40         msg_starting "cronie crond"
41         daemon /usr/sbin/crond $CROND_ARGS
42         RETVAL=$?
43         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/crond
44 }
45
46 stop() {
47         if [ ! -f /var/lock/subsys/crond ]; then
48                 msg_not_running "cronie crond"
49                 return
50         fi
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
78 }
79
80 RETVAL=0
81 # See how we were called.
82 case "$1" in
83   start)
84         start
85         ;;
86   stop)
87         stop
88         ;;
89   restart)
90         stop
91         start
92         ;;
93   try-restart)
94         condrestart 0
95         ;;
96   reload|force-reload|flush-logs)
97         reload
98         ;;
99   status)
100         status --pidfile /var/run/crond.pid crond
101         exit $?
102         ;;
103   *)
104         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}"
105         exit 3
106 esac
107
108 exit $RETVAL
This page took 0.038325 seconds and 3 git commands to generate.