git: 042267e0cdda - main - Explain cron.d

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 10 May 2024 04:36:10 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=042267e0cdda5cd90803b00a3d6a7dd1f403938d

commit 042267e0cdda5cd90803b00a3d6a7dd1f403938d
Author:     Paweł Krawczyk <p+freebsd@krvtz.net>
AuthorDate: 2024-05-10 04:21:18 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-10 04:34:36 +0000

    Explain cron.d
    
    Add details on the format of system cron files, which are mentioned in
    cron(8) which refers here but barely explained here.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1106
---
 usr.sbin/cron/crontab/crontab.5 | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/usr.sbin/cron/crontab/crontab.5 b/usr.sbin/cron/crontab/crontab.5
index 12caa45cff46..e4e6fae0b01b 100644
--- a/usr.sbin/cron/crontab/crontab.5
+++ b/usr.sbin/cron/crontab/crontab.5
@@ -19,7 +19,7 @@
 .\"
 .\" $Id: crontab.5,v 1.2 1998/08/14 00:32:38 vixie Exp $
 .\"
-.Dd March 29, 2020
+.Dd May 10, 2024
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -151,11 +151,15 @@ usually does not read its mail.
 .Pp
 The format of a cron command is very much the V7 standard, with a number of
 upward-compatible extensions.
-Each line has five time and date fields,
-followed by a user name
-(with optional ``:<group>'' and ``/<login-class>'' suffixes)
-if this is the system crontab file,
+.Pp
+Each user cron line has five time and date fields, followed by a command.
+.Pp
+Each line in system crontab (
+.Pa /etc/crontab, /etc/cron.d, /usr/local/etc/cron.d
+) has five time and date fields, followed by a valid user name
+(with optional ``:<group>'' and ``/<login-class>'' suffixes),
 followed by a command.
+.Pp
 Commands are executed by
 .Xr cron 8
 when the minute, hour, and month of year fields match the current time,
@@ -281,9 +285,15 @@ Note, however, that overlap may occur if the job is running when the file
 containing the job is modified and subsequently reloaded.
 The first run is scheduled for the specified number of seconds after cron
 is started or the crontab entry is reloaded.
-.Sh EXAMPLE CRON FILE
+.Sh EXAMPLE SYSTEM CRON FILE
+.Bd -literal
+# sample /etc/cron.d/vmstat
+# run vmstat every five minutes
+# note the username as sixth field!
+*/5 * * * * root vmstat
+.Ed
+.Sh EXAMPLE USER CRON FILE
 .Bd -literal
-
 # use /bin/sh to run commands, overriding the default set by cron
 SHELL=/bin/sh
 # mail any output to `paul', no matter whose crontab this is