ANACRON(8)

๐Ÿ“ฆ
version 1.7.2 ยท 6 versions
, in alpine 3.24, arch rolling, centos-stream 10, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’… ANACRON(8) โ€” the anacron glow-up (manual page, section 8, system administration era)

okay so bestie, welcome to ANACRON(8), the page about anacron โ€” the cron-adjacent icon that runs commands periodically. she's lowkey the main character of "my laptop isn't on 24/7" representation. let's get into it โœจ


๐ŸŒธ NAME ๐ŸŒธ

anacron โ€” runs commands periodically. that's it, that's the vibe. she runs things on a schedule and she does not need your machine to be awake the whole time. periodt.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [-S spooldir] [job]
anacron [-S spooldir] -u [-t anacrontab] [job]
anacron [-V|-h]
anacron -T [-t anacrontab]

four whole moods, bestie. pick your fighter ๐Ÿ’…


๐Ÿ’– DESCRIPTION ๐Ÿ’–

so <pink>Anacron</pink> is used to execute commands periodically, with a frequency specified in <purple>days</purple>. and here's the iconic part: unlike cron(8), it does not assume that the machine is running continuously. no cap. that means it's literally built for machines that are not running 24 hours a day, to control regular jobs as daily, weekly, and monthly jobs. laptops everywhere are screaming with joy ๐Ÿ˜ญ๐Ÿ’–

Anacron reads a list of jobs from the /etc/anacrontab configuration file (see anacrontab(5)). that file contains the list of jobs that Anacron controls. each job entry specifies a <lavender>period in days</lavender>, a <lavender>delay in minutes</lavender>, a <lavender>unique job identifier</lavender>, and a <lavender>shell command</lavender>. all four. no skimping.

for each job, Anacron checks whether this job has been executed in the last n days, where n is the time period specified for that job. if a job has not been executed in n days or more, Anacron runs the job's shell command โ€” but only after waiting for the number of minutes specified as the delay parameter. she's punctual and polite ๐Ÿซถ

after the command exits, Anacron records the date (excludes the hour โ€” yes, the hour is simply not invited) in a special timestamp file for that job, so it knows when to execute that job again. very "i remember everything" of her tbh ๐Ÿฆ‹

when there are no more jobs to be run, Anacron exits. she leaves. she's done. goodbye. ๐Ÿ’€

Anacron only considers jobs whose identifier, as specified in anacrontab(5), matches any of the job command-line arguments. the job command-line arguments can be represented by <cyan>shell wildcard patterns</cyan> โ€” and bestie, be sure to protect them from your shell with adequate quoting. your shell will absolutely eat them otherwise, and then you'll be sad ๐Ÿ™ˆ

specifying no job command-line arguments is equivalent to specifying "*" (that is, all jobs are considered by Anacron). so no args = everyone's invited to the function.

unless Anacron is run with the -d option (specified below ๐Ÿ‘‡), it forks to the background when it starts, and any parent processes exit immediately. she's out of there. nothing personal.

unless Anacron is run with the -s or -n options, it starts jobs immediately when their delay is over. the execution of different jobs is completely independent. they don't know each other. they don't talk. independent queens โœจ

if an executed job generates any output to standard output or to standard error, the output is mailed to the user under whom Anacron is running (usually root), or to the address specified in the MAILTO environment variable in the /etc/anacrontab file, if such exists. if the LOGNAME environment variable is set, it is used in the From: field of the mail. she's forwarding your mess to your inbox, respectfully ๐Ÿ“ฌ

any informative messages generated by Anacron are sent to syslogd(8) or rsyslogd(8) with facility set to cron and priority set to notice. any error messages are sent with the priority error. so when things go bad, syslog hears about it in the group chat too.

"Active" jobs (i.e., jobs that Anacron already decided to run and are now waiting for their delay to pass, and jobs that are currently being executed by Anacron) are <hotpink>"locked"</hotpink>, so that other copies of Anacron cannot run them at the same time. no double-booking in this house. the lock is giving bouncer at the club ๐Ÿงš


โœจ OPTIONS โœจ

  • -f โ€” Forces execution of all jobs, ignoring any timestamps. timestamps? never heard of her. go go go ๐Ÿ”ฅ
  • -u โ€” Updates the timestamps of all jobs to the current date, but does not run any. all the paperwork, none of the work. iconic.
  • -s โ€” Serializes execution of jobs. Anacron does not start a new job before the previous one finished. one at a time, we wait our turn ๐Ÿ’…
  • -n โ€” Runs jobs immediately and ignores the specified delays in the /etc/anacrontab file. this option implies -s. yes, delays are cancelled, and also yes, it's serial now.
  • -d โ€” Does not fork Anacron to the background. in this mode, Anacron will output informational messages to standard error, as well as to syslog. the output of any job is mailed by Anacron. she stays. she narrates. she emails.
  • -q โ€” Suppresses any messages to standard error. only applicable with -d. quiet mode, but only if you're already in -d mode. iykyk
  • -t some_anacrontab โ€” Uses the specified some_anacrontab, rather than the /etc/anacrontab default one. bring your own config, bestie ๐ŸŽ€
  • -T โ€” Anacrontab testing. Tests the /etc/anacrontab configuration file for validity. if there is an error in the file, it is shown on the standard output and Anacron returns the value of 1. valid anacrontabs return the value of 0. vibe check for your config ๐ŸŒˆ
  • -S spooldir โ€” Uses the specified spooldir to store timestamps in. this option is required for users who wish to run anacron themselves. like, actually required. don't skip it ๐Ÿซถ
  • -V โ€” Prints version information, and exits. hello, i am version, goodbye.
  • -h โ€” Prints short usage message, and exits. the tl;dr of the whole page.

โญ SIGNALS โญ

after receiving a SIGUSR1 signal, Anacron waits for any running jobs to finish and then exits. this can be used to stop Anacron cleanly. she's not gonna ghost mid-job โ€” she finishes her sentence first, then leaves. ladies leave cleanly ๐Ÿ’œ


๐ŸŒˆ NOTES ๐ŸŒˆ

make sure your <yellow>time-zone</yellow> is set correctly before Anacron is started, since the time-zone affects the date. this is usually accomplished by setting the TZ environment variable, or by installing a /usr/lib/zoneinfo/localtime file. see tzset(3) for more information. wrong timezone = wrong date = chaos, and not the fun kind ๐Ÿ˜ญ

timestamp files are created in the spool directory for each job specified in an anacrontab. these files are never removed automatically by Anacron, and should be removed by hand if a job is no longer being scheduled. yes, by hand. yes, you. ๐Ÿ™ˆ


๐Ÿฆ‹ FILES ๐Ÿฆ‹

  • /etc/anacrontab โ€” contains specifications of jobs. see anacrontab(5) for a complete description.
  • /var/spool/anacron โ€” this directory is used by Anacron for storing timestamp files.

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

anacrontab(5), cron(8), tzset(3)

the Anacron README file. yes, the README. she said read it ๐Ÿ“–


๐Ÿ’€ BUGS ๐Ÿ’€

  • Anacron never removes timestamp files. remove unused files manually. she will keep them forever, like screenshots from 2019.
  • Anacron uses up to <red>two file descriptors</red> for each active job. it may run out of descriptors if there are lots of active jobs. see echo $(($(ulimit -n) / 2)) for information how many concurrent jobs anacron may run. do the math, bestie ๐Ÿงฎ
  • mail comments, suggestions and bug reports to Sean 'Shaleh' Perry.

๐ŸŒธ AUTHOR ๐ŸŒธ

  • Anacron was originally conceived and implemented by Christian Schwarz.
  • the current implementation is a complete rewrite by Itai Tzur.
  • the code base was maintained by Sean 'Shaleh' Perry.
  • since 2004, it is maintained by Pascal Hakim.
  • for Fedora, Anacron is maintained by Marcela Maลกlรกลˆovรก.

and that's the page, bestie ๐ŸŽ€โœจ this whole thing is cronie, dated 2012-11-22, and it's the ANACRON(8) manual โ€” go forth, schedule responsibly, and remember: she never deletes her timestamp files ๐Ÿ’…๐Ÿ’–

๐Ÿ“ฆ where this page comes from