1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
From: Christian Kastner <ckk@kvr.at>
Date: Fri, 15 Jan 2016 21:50:01 +0100
Subject: Add helpful header to new crontab
When creating a new crontab, prepend a header with a helpful description of the
crontab(5) syntax.
Contributed by Javier Fernández-Sanguino Peña <jfs@debian.org>.
Contributed by Georges Khaznadar <georgesk@debian.org> : this patch's
feature is tested by debian/tests/check_significant_header
Forwarded: no
Last-Update: 2016-01-15
Index: cron/crontab.c
===================================================================
--- cron.orig/crontab.c
+++ cron/crontab.c
@@ -549,6 +549,7 @@ edit_cmd() {
WAIT_T waiter;
PID_T pid, xpid;
mode_t um;
+ int add_help_text = 0;
log_it(RealUser, Pid, "BEGIN EDIT", User);
(void) snprintf(n, MAX_FNAME, CRON_TAB(User));
@@ -563,6 +564,7 @@ edit_cmd() {
perror("/dev/null");
exit(ERROR_EXIT);
}
+ add_help_text = 1;
}
um = umask(077);
@@ -581,6 +583,33 @@ edit_cmd() {
Set_LineNum(1)
+ if (add_help_text) {
+ fprintf(NewCrontab,
+"# Edit this file to introduce tasks to be run by cron.\n"
+"# \n"
+"# Each task to run has to be defined through a single line\n"
+"# indicating with different fields when the task will be run\n"
+"# and what command to run for the task\n"
+"# \n"
+"# To define the time you can provide concrete values for\n"
+"# minute (m), hour (h), day of month (dom), month (mon),\n"
+"# and day of week (dow) or use '*' in these fields (for 'any').\n"
+"# \n"
+"# Notice that tasks will be started based on the cron's system\n"
+"# daemon's notion of time and timezones.\n"
+"# \n"
+"# Output of the crontab jobs (including errors) is sent through\n"
+"# email to the user the crontab file belongs to (unless redirected).\n"
+"# \n"
+"# For example, you can run a backup of all your user accounts\n"
+"# at 5 a.m every week with:\n"
+"# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/\n"
+"# \n"
+"# For more information see the manual pages of crontab(5) and cron(8)\n"
+"# \n"
+"# m h dom mon dow command\n" );
+ }
+
/* ignore the top few comments since we probably put them there.
*/
for (x = 0; x < NHEADER_LINES; x++) {
|