1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#!/bin/sh
# Start/stop the cron daemon.
#
### BEGIN INIT INFO
# Provides: cron
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Regular background program processing daemon
# Description: cron is a standard UNIX program that runs user-specified
# programs at periodic scheduled times. vixie cron adds a
# number of features to the basic UNIX cron, including better
# security and more powerful configuration options.
### END INIT INFO
test -f /usr/sbin/cron || exit 0
PIDFILE=/var/run/crond.pid
# In some systems the pidfile might be (incorrectly) set to /etc
# if this pidfile is present, use it instead.
[ -e /etc/cron.pid ] && PIDFILE=/etc/crond.pid
[ -r /etc/default/cron ] && . /etc/default/cron
. /lib/lsb/init-functions
# Read the system's locale and set cron's locale. This locale
# will be inherited by cron (used to set charset of emails)
# and tasks running under it.
parse_environment ()
{
ENV_FILE="none"
[ -r /etc/environment ] && ENV_FILE="/etc/environment"
[ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
[ $ENV_FILE = none ] && return
for var in LANG LC_ALL LC_CTYPE; do
value=$(egrep "^[^#]*${var}=" $ENV_FILE | tail -n1 | cut -d= -f2)
eval $var=$value
done
}
# Parse the system's environment
if [ "$READ_ENV" = "yes" ] ; then
export LANG LC_ALL LC_CTYPE
parse_environment
fi
case "$1" in
start) log_daemon_msg "Starting periodic command scheduler" "crond"
start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
log_end_msg $?
;;
stop) log_daemon_msg "Stopping periodic command scheduler" "crond"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --name cron
log_end_msg $?
;;
restart) log_daemon_msg "Restarting periodic command scheduler" "crond"
start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name cron
start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
log_end_msg $?
;;
reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "crond"
# cron reloads automatically
log_end_msg 0
;;
*) log_action_msg "Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}"
exit 2
;;
esac
exit 0
|