diff -Nur --from-file=anacron-2.3-13.orig anacron-2.3-13.orig/anacron.8 anacron-2.3-13/anacron.8 --- anacron-2.3-13.orig/anacron.8 2008-12-23 05:20:08.000000000 +0200 +++ anacron-2.3-13/anacron.8 2008-12-23 05:58:31.000000000 +0200 @@ -2,7 +2,7 @@ .SH NAME anacron \- runs commands periodically .SH SYNOPSIS -.B anacron \fR[\fB-s\fR] [\fB-f\fR] [\fB-n\fR] [\fB-d\fR] [\fB-q\fR] +.B anacron \fR[\fB-s\fR] [\fB-f\fR] [\fB-n\fR] [\fB-d\fR] [\fB-q\fR] [\fB-r\fR] [\fB-t anacrontab\fR] [\fB-S spooldir\fR] [\fIjob\fR] ... .br .B anacron [\fB-S spooldir\fR] -u [\fB-t anacrontab\fR] \fR[\fIjob\fR] ... @@ -100,6 +100,12 @@ .B -q Suppress messages to standard error. Only applicable with \fB-d\fR. .TP +.B -r +Require a clean exit (return value 0) from the job before updating the timestamp. +This can be used to run the job again soon (on the next anacron run), +if the job failed for some reason. E.g. backup operation might be required +to be succesful each day. +.TP .B -t anacrontab Use specified anacrontab, rather than the default .TP diff -Nur --from-file=anacron-2.3-13.orig anacron-2.3-13.orig/global.h anacron-2.3-13/global.h --- anacron-2.3-13.orig/global.h 2008-12-23 05:20:08.000000000 +0200 +++ anacron-2.3-13/global.h 2008-12-23 05:48:15.000000000 +0200 @@ -82,6 +82,7 @@ extern int old_umask; extern sigset_t old_sigmask; extern int serialize,force,update_only,now,no_daemon,quiet,testing_only; +extern int require_clean_exit; extern int day_now; extern int year,month,day_of_month; extern int in_background; diff -Nur --from-file=anacron-2.3-13.orig anacron-2.3-13.orig/main.c anacron-2.3-13/main.c --- anacron-2.3-13.orig/main.c 2008-12-23 05:20:08.000000000 +0200 +++ anacron-2.3-13/main.c 2008-12-23 06:17:21.000000000 +0200 @@ -43,6 +43,7 @@ char *spooldir; int serialize, force, update_only, now, no_daemon, quiet, testing_only; /* command-line options */ +int require_clean_exit; char **args; /* vector of "job" command-line arguments */ int nargs; /* number of these */ char *defarg = "*"; @@ -72,7 +73,7 @@ static void print_usage() { - printf("Usage: anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [-S spooldir] [job] ...\n" + printf("Usage: anacron [-s] [-f] [-n] [-d] [-q] [-r] [-t anacrontab] [-S spooldir] [job] ...\n" " anacron [-S spooldir] -u [job] ...\n" " anacron [-V|-h]\n" " anacron -T [-t anacrontab]\n" @@ -82,6 +83,7 @@ " -n Run jobs with no delay, implies -s\n" " -d Don't fork to the background\n" " -q Suppress stderr messages, only applicable with -d\n" + " -r Require clean exit before updating timestamp\n" " -u Update the timestamps without actually running anything\n" " -t Use this anacrontab\n" " -V Print version information\n" @@ -101,10 +103,14 @@ quiet = no_daemon = serialize = force = update_only = now = 0; opterr = 0; - while ((opt = getopt(argc, argv, "sfundqt:TS:Vh")) != EOF) + require_clean_exit = 0; + while ((opt = getopt(argc, argv, "rsfundqt:TS:Vh")) != EOF) { switch (opt) { + case 'r': + require_clean_exit = 1; + break; case 's': serialize = 1; break; diff -Nur --from-file=anacron-2.3-13.orig anacron-2.3-13.orig/runjob.c anacron-2.3-13/runjob.c --- anacron-2.3-13.orig/runjob.c 2008-12-23 05:20:08.000000000 +0200 +++ anacron-2.3-13/runjob.c 2008-12-23 05:45:15.000000000 +0200 @@ -276,14 +276,19 @@ int mail_output; char *m; - update_timestamp(jr); + if(!require_clean_exit) + update_timestamp(jr); unlock(jr); if (file_size(jr->output_fd) > jr->mail_header_size) mail_output = 1; else mail_output = 0; m = mail_output ? " (mailing output)" : ""; if (WIFEXITED(status) && WEXITSTATUS(status) == 0) + { + if(require_clean_exit) + update_timestamp(jr); explain("Job `%s' terminated%s", jr->ident, m); + } else if (WIFEXITED(status)) explain("Job `%s' terminated (exit status: %d)%s", jr->ident, WEXITSTATUS(status), m);