[Pkg-cron-devel] [SCM] Git repository for pkg-cron branch, master, updated. debian/3.0pl1-119-14-g675bc24
Javier Fernandez-Sanguino
jfs at debian.org
Fri Sep 16 23:06:08 UTC 2011
The following commit has been merged in the master branch:
commit 5161fb69478d42076ca85962ad6300147d5512c1
Author: Javier Fernandez-Sanguino <jfs at debian.org>
Date: Sat Sep 17 00:19:53 2011 +0200
Document limitations of the periods that can be defined in crontab syntax and provide workaround (Closes: 640086)
diff --git a/crontab.5 b/crontab.5
index 03122b4..7901509 100644
--- a/crontab.5
+++ b/crontab.5
@@ -311,6 +311,30 @@ environment variable in his
this will affect only the commands executed in the crontab, not the execution
of the crontab tasks themselves.
+The
+.I crontab
+syntax does not make it possible to define all possible periods one could
+image off. For example, it is not straightforward to define the last
+weekday of a month. If a task needs to be run in a specific period of time
+that cannot be defined in the
+.I crontab
+syntaxs the best approach would be to have the program itself check the
+date and time information and continue execution only if the period
+matches the desired one.
+
+If the program itself cannot do the checks then a wrapper script would be
+required. Useful tools that could be used for date analysis are
+.I ncal
+or
+.I calendar
+For example, to run a program the last Saturday of every month you could use
+the following wrapper code:
+
+.nf
+0 4 * * Sat [ "$(date +%e)" = "`ncal | grep $(date +%a | sed -e 's/.$//') | sed -e 's/^.*\s\([0-9]\+\)\s*$/\1/'`" ] && echo "Last Saturday" && program_to_run
+.fi
+
+
.SH DIAGNOSTICS
cron requires that each entry in a crontab end in a newline character. If the
last entry in a crontab is missing a newline (ie, terminated by EOF), cron will
--
Git repository for pkg-cron
More information about the Pkg-cron-devel
mailing list