~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/cron

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Start/stop the cron daemon.
 
3
#
 
4
### BEGIN INIT INFO
 
5
# Provides:          cron
 
6
# Required-Start:    $remote_fs $syslog $time
 
7
# Required-Stop:     $remote_fs $syslog $time
 
8
# Should-Start:      $network $named slapd autofs ypbind nscd nslcd winbind
 
9
# Should-Stop:       $network $named slapd autofs ypbind nscd nslcd winbind
 
10
# Default-Start:     2 3 4 5
 
11
# Default-Stop:
 
12
# Short-Description: Regular background program processing daemon
 
13
# Description:       cron is a standard UNIX program that runs user-specified 
 
14
#                    programs at periodic scheduled times. vixie cron adds a 
 
15
#                    number of features to the basic UNIX cron, including better
 
16
#                    security and more powerful configuration options.
 
17
### END INIT INFO
 
18
 
 
19
PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
20
DESC="cron daemon"
 
21
NAME=cron
 
22
DAEMON=/usr/sbin/cron
 
23
PIDFILE=/var/run/crond.pid
 
24
SCRIPTNAME=/etc/init.d/"$NAME"
 
25
 
 
26
test -f $DAEMON || exit 0
 
27
 
 
28
. /lib/lsb/init-functions
 
29
 
 
30
[ -r /etc/default/cron ] && . /etc/default/cron
 
31
 
 
32
# Read the system's locale and set cron's locale. This is only used for
 
33
# setting the charset of mails generated by cron. To provide locale
 
34
# information to tasks running under cron, see /etc/pam.d/cron.
 
35
#
 
36
# We read /etc/environment, but warn about locale information in
 
37
# there because it should be in /etc/default/locale.
 
38
parse_environment () 
 
39
{
 
40
    for ENV_FILE in /etc/environment /etc/default/locale; do
 
41
        [ -r "$ENV_FILE" ] || continue
 
42
        [ -s "$ENV_FILE" ] || continue
 
43
 
 
44
         for var in LANG LANGUAGE LC_ALL LC_CTYPE; do
 
45
             value=`egrep "^${var}=" "$ENV_FILE" | tail -n1 | cut -d= -f2`
 
46
             [ -n "$value" ] && eval export $var=$value
 
47
 
 
48
             if [ -n "$value" ] && [ "$ENV_FILE" = /etc/environment ]; then
 
49
                 log_warning_msg "/etc/environment has been deprecated for locale information; use /etc/default/locale for $var=$value instead"
 
50
             fi
 
51
         done
 
52
     done
 
53
 
 
54
# Get the timezone set.
 
55
    if [ -z "$TZ" -a -e /etc/timezone ]; then
 
56
        TZ=`cat /etc/timezone` 
 
57
    fi
 
58
}
 
59
 
 
60
# Parse the system's environment
 
61
if [ "$READ_ENV" = "yes" ] ; then
 
62
    parse_environment
 
63
fi
 
64
 
 
65
 
 
66
case "$1" in
 
67
start)  log_daemon_msg "Starting periodic command scheduler" "cron"
 
68
        start_daemon -p $PIDFILE $DAEMON $EXTRA_OPTS
 
69
        log_end_msg $?
 
70
        ;;
 
71
stop)   log_daemon_msg "Stopping periodic command scheduler" "cron"
 
72
        killproc -p $PIDFILE $DAEMON
 
73
        RETVAL=$?
 
74
        [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
 
75
        log_end_msg $RETVAL
 
76
        ;;
 
77
restart) log_daemon_msg "Restarting periodic command scheduler" "cron" 
 
78
        $0 stop
 
79
        $0 start
 
80
        ;;
 
81
reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "cron"
 
82
        # cron reloads automatically
 
83
        log_end_msg 0
 
84
        ;;
 
85
status)
 
86
        status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
 
87
        ;;
 
88
*)      log_action_msg "Usage: /etc/init.d/cron {start|stop|status|restart|reload|force-reload}"
 
89
        exit 2
 
90
        ;;
 
91
esac
 
92
exit 0