PERIODIC(8)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… PERIODIC(8) β€” the system manager's manual, but make it make sense

okay so bestie, you found the page for periodic, living in section 8 of the system manager's manual. she runs the periodic system functions and honestly? she's the reason your server doesn't spiral. let's get into it πŸŽ€


✨ NAME ✨

periodic β€” run periodic system functions

πŸ¦‹ SYNOPSIS πŸ¦‹

periodic daily|weekly|monthly|security|directory ...

🌸 DESCRIPTION 🌸

so periodic is this utility that's meant to be called by cron(8) and its whole job is running shell scripts that live in whatever directory you point it at. lowkey the backbone of your whole system's self-care routine πŸ’–

you must specify one or more of these arguments:

  • daily β€” performs the standard daily periodic executable run. usually happens early in the morning, local time. literally the sunrise shift πŸŒ…
  • weekly β€” performs the standard weekly periodic executable run. usually very early on Saturday mornings. sorry to your weekend 🫢
  • monthly β€” performs the standard monthly periodic executable run. usually on the first day of the month. main character energy, first of the month, periodt πŸ‘‘
  • security β€” performs the standard daily security checks. this is usually spawned by the daily run, so it's giving sidekick-but-make-it-important
  • directory β€” an arbitrary directory containing a set of executables to be run. go off, pick your own adventure

if an argument is an absolute directory name, it gets used exactly as-is. otherwise it's searched for under /etc/periodic and any other directories specified by the local_periodic setting in periodic.conf(5) (more on that below, keep reading πŸ’…).

periodic will run every executable file in the directory or directories you specified. if a file does not have the executable bit set, it's silently ignored. no drama, no error, she just moves on πŸ™ˆ


each script is required to exit with one of these values, and this part is important so pay attention bestie:

  • 0 β€” the script has produced nothing notable in its output. the ⟨basedir⟩_show_success variable controls the masking of this output.
  • 1 β€” the script has produced some notable information in its output. the ⟨basedir⟩_show_info variable controls the masking of this output.
  • 2 β€” the script has produced some warnings due to invalid configuration settings. the ⟨basedir⟩_show_badconfig variable controls the masking of this output.
  • >2 β€” the script has produced output that must not be masked. no hiding allowed, it's coming through πŸ”₯

if the relevant variable (where ⟨basedir⟩ is the base directory in which the script resides) is set to β€œNO” in periodic.conf, periodic will mask the script output. if the variable is not set to either β€œYES” or β€œNO”, it gets a default value as described in periodic.conf(5). defaults, iconic behaviour honestly.

all remaining script output is delivered based on the value of the ⟨basedir⟩_output setting. so like:

  • if it's set to a path name (beginning with a / character), output is simply logged to that file. newsyslog(8) knows about the files /var/log/daily.log, /var/log/weekly.log and /var/log/monthly.log, and if they exist, it will rotate them at the appropriate times. these are therefore good values if you wish to log periodic output. chef's kiss for logging πŸ“
  • if the ⟨basedir⟩_output value does not begin with a / and is not empty, it's assumed to contain a list of email addresses, and the output is mailed to them. if ⟨basedir⟩_show_empty_output is set to β€œNO”, then no mail will be sent if the output was empty. no empty-vibe emails, we respect the inbox πŸ’œ
  • if ⟨basedir⟩_output is not set or is empty, output is sent to standard output.

🌈 ENVIRONMENT 🌈

periodic sets the PATH environment to include all standard system directories, but no additional directories, such as /usr/local/bin. so if executables are added which depend upon other path components, each executable must be responsible for configuring its own appropriate environment. like, do it yourself bestie, she's not your personal assistant 🧚

πŸ’– FILES πŸ’–

  • /etc/crontab β€” the periodic utility is typically called via entries in the system default cron(8) table
  • /etc/periodic β€” the top level directory containing daily, weekly, monthly, and security subdirectories which contain standard system periodic executables
  • /etc/defaults/periodic.conf β€” the periodic.conf system registry contains variables that control the behaviour of periodic and the standard daily, weekly, monthly, and security scripts
  • /etc/periodic.conf, ${LOCALBASE}/etc/periodic.conf β€” this file contains local overrides for the default periodic configuration. your personal touches, your signature scent ✨

⭐ EXIT STATUS ⭐

exit status is 0 on success and 1 if the command fails. simple, clean, no notes.

πŸŽ€ EXAMPLES πŸŽ€

the system crontab should have entries for periodic similar to the following example:

# do daily/weekly/monthly maintenance
0      2       *       *       *       root    periodic daily
0      3       *       *       6       root    periodic weekly
0      5       1       *       *       root    periodic monthly

the /etc/defaults/periodic.conf system registry will typically have a local_periodic variable reading:

local_periodic="${_localbase}/etc/periodic"

where ${_localbase} is being set from within /usr/sbin/periodic. sneaky but valid πŸ’…

to log periodic output instead of receiving it as email, add the following lines to /etc/periodic.conf:

daily_output=/var/log/daily.log
weekly_output=/var/log/weekly.log
monthly_output=/var/log/monthly.log

to only see important information from daily periodic jobs, add the following lines to /etc/periodic.conf:

daily_show_success=NO
daily_show_info=NO
daily_show_badconfig=NO

ngl that last one is the vibe check β€” quiet mode activated 🀫

πŸ’€ DIAGNOSTICS πŸ’€

the command may fail for one of the following reasons:

  • usage: periodic <directory of files to execute> β€” no directory path argument was passed to periodic to specify where the script fragments reside. she's asking nicely, give her a directory 😭
  • <directory> not found β€” self explanatory. it's not there bestie, look again.

πŸ¦‹ SEE ALSO πŸ¦‹

sh(1), crontab(5), periodic.conf(5), cron(8), newsyslog(8)

πŸ”₯ HISTORY πŸ”₯

the periodic utility first appeared in FreeBSD 3.0. a legend from day one πŸ‘‘

🫢 AUTHORS 🫢

  • Paul Traina <pst@FreeBSD.org>
  • Brian Somers <brian@Awfulhak.org>

πŸ™ˆ BUGS πŸ™ˆ

so since one specifies information about a directory using shell variables containing the string ⟨basedir⟩, ⟨basedir⟩ must only contain characters that are valid within a sh(1) variable name β€” alphanumerics and underscores β€” and the first character may not be numeric. no cap, keep it clean or it will absolutely break on you πŸ’€


mwah, that's the whole page bestie β€” with love from the Debian edition, dated June 18, 2020 πŸ’–

πŸ“¦ where this page comes from