From: sgerwk Date: Sat, 28 Oct 2017 10:58:47 +0000 (+0200) Subject: round time on the minute X-Git-Tag: cronie-1.5.2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea6b6d1f7ae40a1555c54bfb15e3fe47e8b4a654;p=cronie round time on the minute --- diff --git a/man/cronnext.1 b/man/cronnext.1 index 4233c42..89e4abe 100644 --- a/man/cronnext.1 +++ b/man/cronnext.1 @@ -12,7 +12,8 @@ cronnext \- time of next job cron will execute .SH DESCRIPTION Determine the time cron will execute the next job. Without arguments, it prints that time considering all crontabs, in number of seconds since the -Epoch. This number can be converted into other formats using +Epoch, rounded to the minute. This number can be converted into other formats +using .BR date (1), like .B date --date @43243254 @@ -44,11 +45,12 @@ file arguments. This is implicit if no file is passed. .BI "\-t " time Determine the next job from this time, instead of now. The time is expressed in number of seconds since the Epoch, as obtained for example by -.BR "date +%s --date \(dqnow + 2 hours\(dq" . +.BR "date +%s --date \(dqnow + 2 hours\(dq" , +and is internally rounded to the minute. .TP .BI "\-q " time -Do not check jobs over this time, expressed in number of seconds since the -Epoch. +Do not check jobs over this time, expressed in the same way as in option +.BR -t . .TP .B \-l Print the whole entries of the jobs that are the next to be executed by cron. diff --git a/src/cronnext.c b/src/cronnext.c index eebe410..306a16e 100644 --- a/src/cronnext.c +++ b/src/cronnext.c @@ -329,7 +329,7 @@ int main(int argn, char *argv[]) { flags = SYSTEM; endtime = 0; printjobs = 0; - start = time(NULL); + start = time(NULL) / 60 * 60; while (-1 != (opt = getopt(argn, argv, "i:e:ast:q:lcfhV"))) { switch (opt) { @@ -346,10 +346,10 @@ int main(int argn, char *argv[]) { flags &= ~SYSTEM; break; case 't': - start = atoi(optarg); + start = atoi(optarg) / 60 * 60; break; case 'q': - end = atoi(optarg); + end = atoi(optarg) / 60 * 60; endtime = 1; break; case 'l':