1 /* vi: set sw=4 ts=4: */
3 * run as root, but NOT setuid root
5 * Copyright 1994 Matthew Dillon (dillon@apollo.west.oic.com)
7 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 //config: bool "crond"
14 //config: select FEATURE_SYSLOG
16 //config: Crond is a background daemon that parses individual crontab
17 //config: files and executes commands on behalf of the users in question.
18 //config: This is a port of dcron from slackware. It uses files of the
19 //config: format /var/spool/cron/crontabs/<username> files, for example:
20 //config: $ cat /var/spool/cron/crontabs/root
21 //config: # Run daily cron jobs at 4:40 every day:
22 //config: 40 4 * * * /etc/cron/daily > /dev/null 2>&1
24 //config:config FEATURE_CROND_D
25 //config: bool "Support option -d to redirect output to stderr"
26 //config: depends on CROND
29 //config: -d N sets loglevel (0:most verbose) and directs all output to stderr.
31 //config:config FEATURE_CROND_CALL_SENDMAIL
32 //config: bool "Report command output via email (using sendmail)"
34 //config: depends on CROND
36 //config: Command output will be sent to corresponding user via email.
38 //config:config FEATURE_CROND_DIR
39 //config: string "crond spool directory"
40 //config: default "/var/spool/cron"
41 //config: depends on CROND || CRONTAB
43 //config: Location of crond spool.
45 //applet:IF_CROND(APPLET(crond, BB_DIR_USR_SBIN, BB_SUID_DROP))
47 //kbuild:lib-$(CONFIG_CROND) += crond.o
49 //usage:#define crond_trivial_usage
50 //usage: "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR"
51 //usage:#define crond_full_usage "\n\n"
52 //usage: " -f Foreground"
53 //usage: "\n -b Background (default)"
54 //usage: "\n -S Log to syslog (default)"
55 //usage: "\n -l N Set log level. Most verbose:0, default:8"
56 //usage: IF_FEATURE_CROND_D(
57 //usage: "\n -d N Set log level, log to stderr"
59 //usage: "\n -L FILE Log to FILE"
60 //usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs"
65 /* glibc frees previous setenv'ed value when we do next setenv()
66 * of the same variable. uclibc does not do this! */
67 #if (defined(__GLIBC__) && !defined(__UCLIBC__)) /* || OTHER_SAFE_LIBC... */
68 # define SETENV_LEAKS 0
70 # define SETENV_LEAKS 1
74 #define CRON_DIR CONFIG_FEATURE_CROND_DIR
75 #define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
77 # define SENDMAIL "sendmail"
80 # define SENDMAIL_ARGS "-ti"
83 # define CRONUPDATE "cron.update"
86 # define MAXLINES 256 /* max lines in non-root crontabs */
90 typedef struct CronFile {
91 struct CronFile *cf_next;
92 struct CronLine *cf_lines;
94 smallint cf_wants_starting; /* bool: one or more jobs ready */
95 smallint cf_has_running; /* bool: one or more jobs running */
96 smallint cf_deleted; /* marked for deletion (but still has running jobs) */
99 typedef struct CronLine {
100 struct CronLine *cl_next;
101 char *cl_cmd; /* shell command */
102 pid_t cl_pid; /* >0:running, <0:needs to be started in this minute, 0:dormant */
103 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
104 int cl_empty_mail_size; /* size of mail header only, 0 if no mailfile */
105 char *cl_mailto; /* whom to mail results, may be NULL */
107 /* ordered by size, not in natural order. makes code smaller: */
108 char cl_Dow[7]; /* 0-6, beginning sunday */
109 char cl_Mons[12]; /* 0-11 */
110 char cl_Hrs[24]; /* 0-23 */
111 char cl_Days[32]; /* 1-31 */
112 char cl_Mins[60]; /* 0-59 */
126 OPT_d = (1 << 6) * ENABLE_FEATURE_CROND_D,
128 #if ENABLE_FEATURE_CROND_D
129 # define DebugOpt (option_mask32 & OPT_d)
136 unsigned log_level; /* = 8; */
137 time_t crontab_dir_mtime;
138 const char *log_filename;
139 const char *crontab_dir_name; /* = CRONTABS; */
140 CronFile *cron_files;
146 #define G (*(struct globals*)&bb_common_bufsiz1)
147 #define INIT_G() do { \
149 G.crontab_dir_name = CRONTABS; \
153 /* 0 is the most verbose, default 8 */
159 /* level >= 20 is "error" */
162 static void crondlog(const char *ctl, ...) __attribute__ ((format (printf, 1, 2)));
163 static void crondlog(const char *ctl, ...)
166 int level = (ctl[0] & 0x1f);
169 if (level >= (int)G.log_level) {
170 /* Debug mode: all to (non-redirected) stderr, */
171 /* Syslog mode: all to syslog (logmode = LOGMODE_SYSLOG), */
172 if (!DebugOpt && G.log_filename) {
173 /* Otherwise (log to file): we reopen log file at every write: */
174 int logfd = open_or_warn(G.log_filename, O_WRONLY | O_CREAT | O_APPEND);
176 xmove_fd(logfd, STDERR_FILENO);
178 /* When we log to syslog, level > 8 is logged at LOG_ERR
179 * syslog level, level <= 8 is logged at LOG_INFO. */
181 bb_verror_msg(ctl + 1, va, /* strerr: */ NULL);
184 vasprintf(&msg, ctl + 1, va);
185 bb_info_msg("%s: %s", applet_name, msg);
194 static const char DowAry[] ALIGN1 =
195 "sun""mon""tue""wed""thu""fri""sat"
198 static const char MonAry[] ALIGN1 =
199 "jan""feb""mar""apr""may""jun""jul""aug""sep""oct""nov""dec"
202 static void ParseField(char *user, char *ary, int modvalue, int off,
203 const char *names, char *ptr)
204 /* 'names' is a pointer to a set of 3-char abbreviations */
210 // this can't happen due to config_read()
217 /* Handle numeric digit or symbol or '*' */
219 n1 = 0; /* everything will be filled */
223 } else if (isdigit(*ptr)) {
226 n1 = strtol(ptr, &endp, 10) + off;
228 n2 = strtol(ptr, &endp, 10) + off;
230 ptr = endp; /* gcc likes temp var for &endp */
235 for (i = 0; names[i]; i += 3) {
236 /* was using strncmp before... */
237 if (strncasecmp(ptr, &names[i], 3) == 0) {
250 /* handle optional range '-' */
254 if (*ptr == '-' && n2 < 0) {
260 * collapse single-value ranges, handle skipmark, and fill
261 * in the character array appropriately.
268 skip = strtol(ptr + 1, &endp, 10);
269 ptr = endp; /* gcc likes temp var for &endp */
273 * fill array, using a failsafe is the easiest way to prevent
282 n1 = (n1 + 1) % modvalue;
285 ary[n1 % modvalue] = 1;
288 if (--failsafe == 0) {
303 crondlog(WARN9 "user %s: parse error at %s", user, base);
307 if (DebugOpt && (G.log_level <= 5)) { /* like LVL5 */
308 /* can't use crondlog, it inserts '\n' */
310 for (i = 0; i < modvalue; ++i)
311 fprintf(stderr, "%d", (unsigned char)ary[i]);
312 bb_putchar_stderr('\n');
316 static void FixDayDow(CronLine *line)
322 for (i = 0; i < ARRAY_SIZE(line->cl_Dow); ++i) {
323 if (line->cl_Dow[i] == 0) {
328 for (i = 0; i < ARRAY_SIZE(line->cl_Days); ++i) {
329 if (line->cl_Days[i] == 0) {
334 if (weekUsed != daysUsed) {
336 memset(line->cl_Days, 0, sizeof(line->cl_Days));
338 memset(line->cl_Dow, 0, sizeof(line->cl_Dow));
343 * delete_cronfile() - delete user database
345 * Note: multiple entries for same user may exist if we were unable to
346 * completely delete a database due to running processes.
348 //FIXME: we will start a new job even if the old job is running
349 //if crontab was reloaded: crond thinks that "new" job is different from "old"
350 //even if they are in fact completely the same. Example
353 // 0-59 * * * * long_running_job2
354 //User edits crontab to:
355 // 0-59 * * * * job1_updated
356 // 0-59 * * * * long_running_job2
357 //Bug: crond can now start another long_running_job2 even if old one
359 //OTOH most other versions of cron do not wait for job termination anyway,
360 //they end up with multiple copies of jobs if they don't terminate soon enough.
361 static void delete_cronfile(const char *userName)
363 CronFile **pfile = &G.cron_files;
366 while ((file = *pfile) != NULL) {
367 if (strcmp(userName, file->cf_username) == 0) {
368 CronLine **pline = &file->cf_lines;
371 file->cf_has_running = 0;
372 file->cf_deleted = 1;
374 while ((line = *pline) != NULL) {
375 if (line->cl_pid > 0) {
376 file->cf_has_running = 1;
377 pline = &line->cl_next;
379 *pline = line->cl_next;
384 if (file->cf_has_running == 0) {
385 *pfile = file->cf_next;
386 free(file->cf_username);
391 pfile = &file->cf_next;
395 static void load_crontab(const char *fileName)
397 struct parser_t *parser;
401 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
405 delete_cronfile(fileName);
407 if (!getpwnam(fileName)) {
408 crondlog(LVL7 "ignoring file '%s' (no such user)", fileName);
412 parser = config_open(fileName);
416 maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES;
418 if (fstat(fileno(parser->fp), &sbuf) == 0 && sbuf.st_uid == DAEMON_UID) {
419 CronFile *file = xzalloc(sizeof(CronFile));
423 file->cf_username = xstrdup(fileName);
424 pline = &file->cf_lines;
430 crondlog(WARN9 "user %s: too many lines", fileName);
434 n = config_read(parser, tokens, 6, 1, "# \t", PARSE_NORMAL | PARSE_KEEP_COPY);
439 crondlog(LVL5 "user:%s entry:%s", fileName, parser->data);
441 /* check if line is setting MAILTO= */
442 if (0 == strncmp(tokens[0], "MAILTO=", 7)) {
443 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
445 mailTo = (tokens[0][7]) ? xstrdup(&tokens[0][7]) : NULL;
446 #endif /* otherwise just ignore such lines */
449 //TODO: handle SHELL=, HOME= too? "man crontab" says:
452 //where the spaces around the equal-sign (=) are optional, and any subsequent
453 //non-leading spaces in value will be part of the value assigned to name.
454 //The value string may be placed in quotes (single or double, but matching)
455 //to preserve leading or trailing blanks.
457 //Several environment variables are set up automatically by the cron(8) daemon.
458 //SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd
459 //line of the crontab's owner. HOME and SHELL may be overridden by settings
460 //in the crontab; LOGNAME may not.
461 /* check if a minimum of tokens is specified */
464 *pline = line = xzalloc(sizeof(*line));
465 /* parse date ranges */
466 ParseField(file->cf_username, line->cl_Mins, 60, 0, NULL, tokens[0]);
467 ParseField(file->cf_username, line->cl_Hrs, 24, 0, NULL, tokens[1]);
468 ParseField(file->cf_username, line->cl_Days, 32, 0, NULL, tokens[2]);
469 ParseField(file->cf_username, line->cl_Mons, 12, -1, MonAry, tokens[3]);
470 ParseField(file->cf_username, line->cl_Dow, 7, 0, DowAry, tokens[4]);
472 * fix days and dow - if one is not "*" and the other
473 * is "*", the other is set to 0, and vise-versa
476 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
477 /* copy mailto (can be NULL) */
478 line->cl_mailto = xstrdup(mailTo);
481 line->cl_cmd = xstrdup(tokens[5]);
483 crondlog(LVL5 " command:%s", tokens[5]);
485 pline = &line->cl_next;
486 //bb_error_msg("M[%s]F[%s][%s][%s][%s][%s][%s]", mailTo, tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5]);
490 file->cf_next = G.cron_files;
493 config_close(parser);
496 static void process_cron_update_file(void)
501 fi = fopen_for_read(CRONUPDATE);
504 while (fgets(buf, sizeof(buf), fi) != NULL) {
505 /* use first word only */
506 skip_non_whitespace(buf)[0] = '\0';
513 static void rescan_crontab_dir(void)
517 /* Delete all files until we only have ones with running jobs (or none) */
519 for (file = G.cron_files; file; file = file->cf_next) {
520 if (!file->cf_deleted) {
521 delete_cronfile(file->cf_username);
526 /* Remove cron update file */
528 /* Re-chdir, in case directory was renamed & deleted */
529 if (chdir(G.crontab_dir_name) < 0) {
530 crondlog(DIE9 "chdir(%s)", G.crontab_dir_name);
533 /* Scan directory and add associated users */
535 DIR *dir = opendir(".");
539 crondlog(DIE9 "chdir(%s)", "."); /* exits */
540 while ((den = readdir(dir)) != NULL) {
541 if (strchr(den->d_name, '.') != NULL) {
544 load_crontab(den->d_name);
551 /* We set environment *before* vfork (because we want to use vfork),
552 * so we cannot use setenv() - repeated calls to setenv() may leak memory!
553 * Using putenv(), and freeing memory after unsetenv() won't leak */
554 static void safe_setenv(char **pvar_val, const char *var, const char *val)
556 char *var_val = *pvar_val;
559 bb_unsetenv_and_free(var_val);
561 *pvar_val = xasprintf("%s=%s", var, val);
566 static void set_env_vars(struct passwd *pas)
569 safe_setenv(&G.env_var_user, "USER", pas->pw_name);
570 safe_setenv(&G.env_var_home, "HOME", pas->pw_dir);
571 /* if we want to set user's shell instead: */
572 /*safe_setenv(G.env_var_shell, "SHELL", pas->pw_shell);*/
574 xsetenv("USER", pas->pw_name);
575 xsetenv("HOME", pas->pw_dir);
577 /* currently, we use constant one: */
578 /*setenv("SHELL", DEFAULT_SHELL, 1); - done earlier */
581 static void change_user(struct passwd *pas)
583 /* careful: we're after vfork! */
584 change_identity(pas); /* - initgroups, setgid, setuid */
585 if (chdir(pas->pw_dir) < 0) {
586 crondlog(WARN9 "chdir(%s)", pas->pw_dir);
587 if (chdir(CRON_DIR) < 0) {
588 crondlog(DIE9 "chdir(%s)", CRON_DIR); /* exits */
593 // TODO: sendmail should be _run-time_ option, not compile-time!
594 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
597 fork_job(const char *user, int mailFd,
599 const char *shell_cmd /* if NULL, we run sendmail */
604 /* prepare things before vfork */
605 pas = getpwnam(user);
607 crondlog(WARN9 "can't get uid for %s", user);
615 /* initgroups, setgid, setuid, and chdir to home or CRON_DIR */
618 crondlog(LVL5 "child running %s", prog);
621 xmove_fd(mailFd, shell_cmd ? 1 : 0);
624 /* crond 3.0pl1-100 puts tasks in separate process groups */
626 execlp(prog, prog, (shell_cmd ? "-c" : SENDMAIL_ARGS), shell_cmd, (char *) NULL);
627 crondlog(ERR20 "can't execute '%s' for user %s", prog, user);
629 fdprintf(1, "Exec failed: %s -c %s\n", prog, shell_cmd);
635 crondlog(ERR20 "can't vfork");
638 } /* else: PARENT, FORK SUCCESS */
641 * Close the mail file descriptor.. we can't just leave it open in
642 * a structure, closing it later, because we might run out of descriptors
650 static void start_one_job(const char *user, CronLine *line)
656 line->cl_empty_mail_size = 0;
658 if (line->cl_mailto) {
659 /* Open mail file (owner is root so nobody can screw with it) */
660 snprintf(mailFile, sizeof(mailFile), "%s/cron.%s.%d", CRON_DIR, user, getpid());
661 mailFd = open(mailFile, O_CREAT | O_TRUNC | O_WRONLY | O_EXCL | O_APPEND, 0600);
664 fdprintf(mailFd, "To: %s\nSubject: cron: %s\n\n", line->cl_mailto,
666 line->cl_empty_mail_size = lseek(mailFd, 0, SEEK_CUR);
668 crondlog(ERR20 "can't create mail file %s for user %s, "
669 "discarding output", mailFile, user);
673 line->cl_pid = fork_job(user, mailFd, DEFAULT_SHELL, line->cl_cmd);
675 if (line->cl_pid <= 0) {
678 /* rename mail-file based on pid of process */
679 char *mailFile2 = xasprintf("%s/cron.%s.%d", CRON_DIR, user, (int)line->cl_pid);
680 rename(mailFile, mailFile2); // TODO: xrename?
687 * process_finished_job - called when job terminates and when mail terminates
689 static void process_finished_job(const char *user, CronLine *line)
702 if (line->cl_empty_mail_size <= 0) {
703 /* End of job and no mail file, or end of sendmail job */
708 * End of primary job - check for mail file.
709 * If size has changed and the file is still valid, we send it.
711 snprintf(mailFile, sizeof(mailFile), "%s/cron.%s.%d", CRON_DIR, user, (int)pid);
712 mailFd = open(mailFile, O_RDONLY);
718 if (fstat(mailFd, &sbuf) < 0
719 || sbuf.st_uid != DAEMON_UID
720 || sbuf.st_nlink != 0
721 || sbuf.st_size == line->cl_empty_mail_size
722 || !S_ISREG(sbuf.st_mode)
727 line->cl_empty_mail_size = 0;
728 /* if (line->cl_mailto) - always true if cl_empty_mail_size was nonzero */
729 line->cl_pid = fork_job(user, mailFd, SENDMAIL, NULL);
732 #else /* !ENABLE_FEATURE_CROND_CALL_SENDMAIL */
734 static void start_one_job(const char *user, CronLine *line)
739 pas = getpwnam(user);
741 crondlog(WARN9 "can't get uid for %s", user);
745 /* Prepare things before vfork */
748 /* Fork as the user in question and run program */
752 /* initgroups, setgid, setuid, and chdir to home or CRON_DIR */
755 crondlog(LVL5 "child running %s", DEFAULT_SHELL);
757 /* crond 3.0pl1-100 puts tasks in separate process groups */
759 execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_cmd, (char *) NULL);
760 crondlog(ERR20 "can't execute '%s' for user %s", DEFAULT_SHELL, user);
765 crondlog(ERR20 "can't vfork");
772 #define process_finished_job(user, line) ((line)->cl_pid = 0)
774 #endif /* !ENABLE_FEATURE_CROND_CALL_SENDMAIL */
777 * Determine which jobs need to be run. Under normal conditions, the
778 * period is about a minute (one scan). Worst case it will be one
781 static void flag_starting_jobs(time_t t1, time_t t2)
785 /* Find jobs > t1 and <= t2 */
787 for (t = t1 - t1 % 60; t <= t2; t += 60) {
796 for (file = G.cron_files; file; file = file->cf_next) {
798 crondlog(LVL5 "file %s:", file->cf_username);
799 if (file->cf_deleted)
801 for (line = file->cf_lines; line; line = line->cl_next) {
803 crondlog(LVL5 " line %s", line->cl_cmd);
804 if (line->cl_Mins[ptm->tm_min]
805 && line->cl_Hrs[ptm->tm_hour]
806 && (line->cl_Days[ptm->tm_mday] || line->cl_Dow[ptm->tm_wday])
807 && line->cl_Mons[ptm->tm_mon]
810 crondlog(LVL5 " job: %d %s",
811 (int)line->cl_pid, line->cl_cmd);
813 if (line->cl_pid > 0) {
814 crondlog(LVL8 "user %s: process already running: %s",
815 file->cf_username, line->cl_cmd);
816 } else if (line->cl_pid == 0) {
818 file->cf_wants_starting = 1;
826 static void start_jobs(void)
831 for (file = G.cron_files; file; file = file->cf_next) {
832 if (!file->cf_wants_starting)
835 file->cf_wants_starting = 0;
836 for (line = file->cf_lines; line; line = line->cl_next) {
838 if (line->cl_pid >= 0)
841 start_one_job(file->cf_username, line);
843 crondlog(LVL8 "USER %s pid %3d cmd %s",
844 file->cf_username, (int)pid, line->cl_cmd);
846 file->cf_wants_starting = 1;
849 file->cf_has_running = 1;
856 * Check for job completion, return number of jobs still running after
859 static int check_completions(void)
863 int num_still_running = 0;
865 for (file = G.cron_files; file; file = file->cf_next) {
866 if (!file->cf_has_running)
869 file->cf_has_running = 0;
870 for (line = file->cf_lines; line; line = line->cl_next) {
873 if (line->cl_pid <= 0)
876 r = waitpid(line->cl_pid, NULL, WNOHANG);
877 if (r < 0 || r == line->cl_pid) {
878 process_finished_job(file->cf_username, line);
879 if (line->cl_pid == 0) {
880 /* sendmail was not started for it */
883 /* else: sendmail was started, job is still running, fall thru */
885 /* else: r == 0: "process is still running" */
886 file->cf_has_running = 1;
888 //FIXME: if !file->cf_has_running && file->deleted: delete it!
889 //otherwise deleted entries will stay forever, right?
890 num_still_running += file->cf_has_running;
892 return num_still_running;
895 int crond_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
896 int crond_main(int argc UNUSED_PARAM, char **argv)
905 /* "-b after -f is ignored", and so on for every pair a-b */
906 opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l")
907 /* -l and -d have numeric param */
908 ":l+" IF_FEATURE_CROND_D(":d+");
909 opts = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"),
910 &G.log_level, &G.log_filename, &G.crontab_dir_name
911 IF_FEATURE_CROND_D(,&G.log_level));
912 /* both -d N and -l N set the same variable: G.log_level */
914 if (!(opts & OPT_f)) {
915 /* close stdin, stdout, stderr.
916 * close unused descriptors - don't need them. */
917 bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
920 if (!(opts & OPT_d) && G.log_filename == NULL) {
921 /* logging to syslog */
922 openlog(applet_name, LOG_CONS | LOG_PID, LOG_CRON);
923 logmode = LOGMODE_SYSLOG;
926 xchdir(G.crontab_dir_name);
927 //signal(SIGHUP, SIG_IGN); /* ? original crond dies on HUP... */
928 xsetenv("SHELL", DEFAULT_SHELL); /* once, for all future children */
929 crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level);
930 rescan_crontab_dir();
931 write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid");
944 /* Synchronize to 1 minute, minimum 1 second */
945 sleep(sleep_time - (time(NULL) % sleep_time) + 1);
948 dt = (long)t2 - (long)t1;
951 * The file 'cron.update' is checked to determine new cron
952 * jobs. The directory is rescanned once an hour to deal
955 * Check for time jump. Disparities over an hour either way
956 * result in resynchronization. A negative disparity
957 * less than an hour causes us to effectively sleep until we
958 * match the original time (i.e. no re-execution of jobs that
959 * have just been run). A positive disparity less than
960 * an hour causes intermediate jobs to be run, but only once
963 * When running jobs, the inequality used is greater but not
964 * equal to t1, and less then or equal to t2.
966 if (stat(G.crontab_dir_name, &sbuf) != 0)
967 sbuf.st_mtime = 0; /* force update (once) if dir was deleted */
968 if (G.crontab_dir_mtime != sbuf.st_mtime) {
969 G.crontab_dir_mtime = sbuf.st_mtime;
974 rescan_crontab_dir();
976 process_cron_update_file();
978 crondlog(LVL5 "wakeup dt=%ld", dt);
979 if (dt < -60 * 60 || dt > 60 * 60) {
980 crondlog(WARN9 "time disparity of %ld minutes detected", dt / 60);
981 /* and we do not run any jobs in this case */
983 /* Usual case: time advances forward, as expected */
984 flag_starting_jobs(t1, t2);
987 if (check_completions() > 0) {
988 /* some jobs are still running */
992 /* else: time jumped back, do not run any jobs */
995 return 0; /* not reached */