mcron.texi 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. \input texinfo
  2. @c %**start of header
  3. @setfilename mcron.info
  4. @include config.texi
  5. @include version.texi
  6. @settitle mcron @value{VERSION}
  7. @c %**end of header
  8. @syncodeindex fn cp
  9. @copying This manual is for GNU mcron (version @value{VERSION}), which is a
  10. program for running jobs at scheduled times.
  11. Copyright @copyright{} 2003, 2005, 2006, 2012, 2014 Dale Mellor
  12. @quotation
  13. Permission is granted to copy, distribute and/or modify this
  14. document under the terms of the GNU Free Documentation License,
  15. Version 1.3 or any later version published by the Free Software
  16. Foundation; with no Invariant Sections, no Front-Cover Texts and
  17. no Back-Cover Texts. A copy of the license is included in the
  18. section entitled ``GNU Free Documentation License''.
  19. @end quotation
  20. @end copying
  21. @ifinfo
  22. @dircategory Individual utilities
  23. @direntry
  24. * mcron: (mcron). Run jobs at scheduled times.
  25. @end direntry
  26. @end ifinfo
  27. @titlepage
  28. @title mcron - Mellor's cron daemon
  29. @author Dale Mellor
  30. @page
  31. @vskip 0pt plus 1fill
  32. @c @insertcopying
  33. @end titlepage
  34. @contents
  35. @ifnottex
  36. @node Top, Introduction, (dir), (dir)
  37. @top mcron
  38. This file documents the @code{mcron} command (Mellor's cron) for
  39. running jobs at scheduled times.
  40. @c @insertcopying
  41. @end ifnottex
  42. @menu
  43. * Introduction:: Introducing mcron.
  44. * Simple examples:: How to use mcron 99.9% of the time.
  45. * Syntax:: All the possibilities for configuring cron jobs.
  46. * Invoking:: What happens when you run the mcron command.
  47. * Guile modules:: Incorporating mcron into another Guile program.
  48. * GNU Free Documentation License:: The license of this manual.
  49. * Index:: The complete index.
  50. @detailmenu
  51. --- The Detailed Node Listing ---
  52. Simple examples
  53. * Guile Simple Examples::
  54. * Vixie Simple Examples::
  55. Full available syntax
  56. * Guile Syntax::
  57. * Extended Guile examples::
  58. * Vixie Syntax::
  59. Extended Guile examples
  60. * AT commands::
  61. * Every second Sunday::
  62. * Two hours every day::
  63. * Missing the first appointment::
  64. * Penultimate day of every month::
  65. Vixie
  66. * Paul Vixie's copyright::
  67. * Crontab file::
  68. * Incompatibilities with old Unices::
  69. Detailed invoking
  70. * Invoking mcron::
  71. * Invoking cron or crond::
  72. * Invoking crontab::
  73. * Behaviour on laptops::
  74. * Exit codes::
  75. Guile modules
  76. * The base module:: The job list and execution loop.
  77. * The redirect module:: Sending output of jobs to a mail box.
  78. * The vixie-time module:: Parsing vixie-style time specifications.
  79. * The job-specifier module:: All commands for scheme configuration files.
  80. * The vixie-specification module:: Commands for reading vixie-style crontabs.
  81. @end detailmenu
  82. @end menu
  83. @node Introduction, Simple examples, Top, Top
  84. @chapter Introducing mcron
  85. @cindex introduction
  86. @cindex mcron
  87. The mcron program represents a complete re-think of the cron concept
  88. originally found in the Berkeley and AT&T unices, and subsequently
  89. rationalized by Paul Vixie. The original idea was to have a daemon
  90. that wakes up every minute, scans a set of files under a special
  91. directory, and determines from those files if any shell commands
  92. should be executed in this minute.
  93. The new idea is to read the required command instructions, work out
  94. which command needs to be executed next, and then sleep until the
  95. inferred time has arrived. On waking the commands are run, and the
  96. time of the next command is computed. Furthermore, the specifications
  97. are written in scheme, allowing at the same time simple command
  98. execution instructions and very much more flexible ones to be composed
  99. than the original Vixie format. This has several useful advantages
  100. over the original idea. (Changes to user crontabs are signalled
  101. directly to mcron by the crontab program; cron must still scan the
  102. /etc/crontab file once every minute, although use of this file is
  103. highly discouraged and this behaviour can be turned off).
  104. @cindex advantages of mcron
  105. @itemize @bullet
  106. @item
  107. Does not consume CPU resources when not needed. Many cron daemons only
  108. run jobs once an hour, or even just once a day.
  109. @item
  110. Can easily allow for finer time-points to be specified,
  111. i.e. seconds. In principle this could be extended to microseconds, but
  112. this is not implemented.
  113. @item
  114. Times can be more or less regular. For example, a job that runs
  115. every 17 hours can be specified, or a job that runs on the first
  116. Sunday of every month.
  117. @item
  118. Times can be dynamic. Arbitrary Guile (scheme) code can be provided to
  119. compute the next time that a command needs to be run. This could, for
  120. example, take the system load into consideration.
  121. @item
  122. Turns out to be easy to provide complete backwards compatibility with
  123. Vixie cron.
  124. @item
  125. Each user looks after his own files in his own directory. He can use
  126. more than one to break up complicated cron specifications.
  127. @item
  128. Each user can run his own daemon. This removes the need for suid
  129. programs to manipulate the crontabs, and eliminates many security
  130. concerns that surround all existing cron programs.
  131. @item
  132. The user can obtain an advance schedule of all the jobs that are due
  133. to run.
  134. @item
  135. Vixie cron is implemented in 4500 lines of C code; mcron is 2000 lines
  136. of scheme, despite the fact that it offers many more features and much
  137. more flexibility, and complete compatibility with Vixie cron.
  138. @end itemize
  139. A full discussion of the design and philosophy of mcron can be found
  140. in the white paper at
  141. @url{http://www.gnu.org/software/mcron/design.html}.
  142. @node Simple examples, Syntax, Introduction, Top
  143. @chapter Simple examples
  144. The vast majority of uses of cron are sublimely simple: run a program
  145. every hour, or every day. With this in mind the design of mcron has
  146. been to allow such simple specifications to be made easily. The
  147. examples show how to create the command descriptions, and subsequently
  148. how to run mcron to make them happen.
  149. @menu
  150. * Guile Simple Examples::
  151. * Vixie Simple Examples::
  152. @end menu
  153. @node Guile Simple Examples, Vixie Simple Examples, Simple examples, Simple examples
  154. @section Guile
  155. @cindex guile examples
  156. @cindex examples, guile
  157. @cindex example, run a program every hour
  158. You have an executable @code{my-program} in your home directory, which
  159. you want to run every hour. Create a file @code{job.guile} in
  160. directory @code{~/.config/cron} (this path may be altered by the
  161. @code{$XDG_CONFIG_HOME} environment variable) with the following
  162. contents
  163. @example
  164. (job '(next-hour) "my-program")
  165. @end example
  166. then run the command @code{mcron}.
  167. Want the program to run fifteen minutes past the hour, every two
  168. hours? Edit the file to read
  169. @example
  170. (job
  171. '(next-minute-from
  172. (next-hour (range 0 24 2))
  173. 15)
  174. "my-program")
  175. @end example
  176. and run the command @code{mcron}.
  177. Or, if you are not comfortable with Scheme, you could use (and see
  178. also the next section)
  179. @example
  180. (job "15 */2 * * *" "my-program")
  181. @end example
  182. and run the @code{mcron} command.
  183. If you want to run other jobs, you can either add more lines to this
  184. file, or you can create other files in your @code{.config/cron} directory
  185. with the @code{.guile} extension. Alternatively, you can use any file
  186. you want and pass it as an argument to @code{mcron}, or even pipe the
  187. commands into the standard input.
  188. @node Vixie Simple Examples, , Guile Simple Examples, Simple examples
  189. @section Vixie
  190. @cindex examples
  191. @cindex examples, vixie
  192. @cindex vixie examples
  193. You have an executable @code{my-program} in your home directory, which
  194. you want to run every hour. Create a file @code{job.vixie} in directory
  195. @code{~/.cron} with the following contents
  196. @example
  197. 0 * * * * my-program
  198. @end example
  199. then run the command @code{mcron}.
  200. @cindex vixie compatibility
  201. @cindex compatibility
  202. Alternatively (full compatibility with Vixie cron), set your
  203. environment variable @code{EDITOR} to your favorite editor, run
  204. @code{crontab -e}, put the above line into the edit buffer, save and
  205. exit. For this to work the @code{cron} daemon must be already running
  206. on your system, as root.
  207. @node Syntax, Invoking, Simple examples, Top
  208. @chapter Full available syntax
  209. @menu
  210. * Guile Syntax::
  211. * Extended Guile examples::
  212. * Vixie Syntax::
  213. @end menu
  214. @node Guile Syntax, Extended Guile examples, Syntax, Syntax
  215. @section Guile Syntax
  216. @subsection Job specification
  217. @cindex guile syntax
  218. @cindex syntax, guile
  219. @findex job
  220. In Guile-formatted configuration files each command that needs executing is
  221. introduced with the @code{job} function. This function always takes two
  222. arguments, the first a time specification, and the second a command
  223. specification. An optional third argument may contain a string to display
  224. when this job is listed in a schedule. Additionally a @var{user} keyword
  225. argument can be supplied to use a different user than the one defined in
  226. @code{configuration-user} global variable.
  227. @cindex time specification, procedure
  228. @cindex procedure time specification
  229. The first argument can be a procedure, a list, or a string. If a
  230. function is supplied, it must take exactly one argument, which will be
  231. the ``current'' time in UNIX format, and the return value of the
  232. function must be the time in UNIX format when this action should next
  233. be run. The following functions are available to facilitate the
  234. computation:
  235. @findex next-second-from
  236. @code{(next-second-from time . args)} without arguments this
  237. returns the second after the current one. With the extra arguments,
  238. these form a list of seconds in the minute when the action should run,
  239. and the function will return the time of the next allowed second
  240. (which may be in the next minute of the hour). @footnote{Note that
  241. while commands can be scheduled to run at any second, it is unlikely
  242. that they will be executed then but some time shortly thereafter,
  243. depending on the load on the system and the number of jobs that mcron
  244. has to start at the same time.}
  245. @findex next-minute-from
  246. @findex next-hour-from
  247. @findex next-day-from
  248. @findex next-week-from
  249. @findex next-month-from
  250. @findex next-year-from
  251. Similarly to @code{next-second-from}, there are also
  252. @code{next-minute-from}, @code{next-hour-from}, @code{next-day-from},
  253. @code{next-week-from}, @code{next-month-from}, @code{next-year-from}.
  254. @findex range
  255. Furthermore, the optional argument can be fulfilled by the function
  256. @code{(range start end . step)}, which will provide a list of values
  257. from start to (but not including) end, with the step if given. For
  258. example @code{(range 0 10 2)} will yield the list @code{'(0 2 4 6 8)}.
  259. @findex next-second
  260. @findex next-minute
  261. @findex next-hour
  262. @findex next-day
  263. @findex next-week
  264. @findex next-month
  265. @findex next-year
  266. @cindex time specification, list
  267. @cindex list time specification
  268. If the first argument to the @code{job} function is a list, it is
  269. taken to be program code made up of the functions @code{(next-second
  270. . args)}, @code{(next-minute...)}, etc, where the optional arguments
  271. can be supplied with the @code{(range)} function above (these
  272. functions are analogous to the ones above except that they implicitly
  273. assume the current time; it is supplied by the mcron base when the
  274. list is eval'd).
  275. @cindex time specification
  276. @cindex time specification, string
  277. @cindex string time specification
  278. @cindex time specification, vixie-style
  279. @cindex vixie-style time specification
  280. If the first argument to the @code{job} function is a string, it is
  281. expected to be a Vixie cron-style time specification. See the section
  282. on Vixie syntax for this.
  283. @cindex job execution
  284. @cindex command execution
  285. @cindex execution
  286. The second argument to the @code{(job)} function can be either a string, a
  287. list, or a function. The command is executed in the home directory and with
  288. the UID of @var{user}. If a string is passed, it is assumed to be shell
  289. script and is executed with the user's default shell. If a list is passed it
  290. is assumed to be scheme code and is eval'd as such. A supplied function
  291. should take exactly zero arguments, and will be called at the pertinent times.
  292. @subsection Sending output as e-mail
  293. @cindex email output
  294. @cindex email from guile script
  295. @cindex standard input to commands
  296. @findex with-mail-out
  297. When jobs are specified in a vixie-style configuration, the command is
  298. broken at a percentage sign, and the stuff that comes after this is
  299. sent into the command's standard input. Furthermore, any output from
  300. the command is mailed to the user. This functionality is provided for
  301. compatibility with Vixie cron, but it is also available to scheme
  302. configuration files. The command (with-mail-out action . user) can be
  303. used to direct output from the action (which may be a procedure, list,
  304. or string) into an e-mail to the user.
  305. In the case that the action is a string, then percentage signs are
  306. processed as per the vixie specifications, and information is piped to
  307. the shell command's standard input.
  308. @subsection Setting environment variables
  309. @cindex environment variables in scheme
  310. @cindex setting environment variables
  311. @findex append-environment-mods
  312. Also for compatibility with Vixie cron, mcron has the ability to set
  313. environment variables in configuration files. To access this
  314. functionality from a scheme configuration file, use the command
  315. (append-environment-mods name value), where name is the name of an
  316. environment variable, and value is the value put to it. A value of #f
  317. will remove the variable from the environment.
  318. Note that environment modifications are accumulated as the
  319. configuration file is processed, so when a job actually runs, its
  320. environment will be modified according to the modifications specified
  321. before the job specification in the configuration file.
  322. @node Extended Guile examples, Vixie Syntax, Guile Syntax, Syntax
  323. @section Extended Guile examples
  324. @cindex examples, extended guile
  325. @cindex extended guile examples
  326. While Guile gives you flexibility to do anything, and the power to
  327. represent complex requirements succinctly, things are not always as
  328. they seem. The following examples illustrate some pitfalls, and
  329. demonstrate how to code around them.
  330. @menu
  331. * AT commands::
  332. * Every second Sunday::
  333. * Two hours every day::
  334. * Missing the first appointment::
  335. * Penultimate day of every month::
  336. @end menu
  337. @node AT commands, Every second Sunday, Extended Guile examples, Extended Guile examples
  338. @subsection Synthesizing ``at'' commands
  339. @cindex at command
  340. The current implementation of mcron does not provide for an at command
  341. (a command-line program that allows the user to specify that a job
  342. runs exactly once at a certain time). This can, however, be achieved.
  343. Suppose the program @code{my-program} needs to be run at midnight
  344. tonight. A Guile script like the following would work (but a printed
  345. schedule, obtained with the @code{--schedule} option, will show
  346. superfluous entries).
  347. @example
  348. (job '(next-day)
  349. (lambda () (system "my-program")
  350. (kill (getppid) SIGINT)))
  351. @end example
  352. @node Every second Sunday, Two hours every day, AT commands, Extended Guile examples
  353. @subsection Every second Sunday
  354. @cindex examples, every second sunday
  355. To run @code{my-program} on the second Sunday of every month, a Guile
  356. script like the following should suffice (it is left as an exercise to
  357. the student to understand how this works!).
  358. @example
  359. (job (lambda (current-time)
  360. (let* ((next-month (next-month-from current-time))
  361. (first-day (tm:wday (localtime next-month)))
  362. (second-sunday (if (eqv? first-day 0)
  363. 8
  364. (- 14 first-day))))
  365. (+ next-month (* 24 60 60 second-sunday))))
  366. "my-program")
  367. @end example
  368. @node Two hours every day, Missing the first appointment, Every second Sunday, Extended Guile examples
  369. @subsection Two hours every day
  370. @cindex examples, two hours every day
  371. @cindex pitfalls, two hours every day
  372. Surprisingly perhaps, the following will @strong{not} have the desired
  373. effect.
  374. @example
  375. (job '(next-hour-from (next-day) '(1 2))
  376. "my-program")
  377. @end example
  378. Rather than running the my-program program at one o'clock and two
  379. o'clock every day, it will only run it at one o'clock. This is because
  380. each time mcron has to compute the next time to run the command, it
  381. first obtains the next day, and then finds the earliest hour in that
  382. day to run at. Thus, after running the command at one o'clock, the
  383. program first skips forwards to the next midnight (missing the two
  384. o'clock appointment), and then finds the next one o'clock schedule.
  385. The following simple command is the correct way to specify this
  386. behaviour.
  387. @example
  388. (job '(next-hour '(1 2)) "my-program")
  389. @end example
  390. @node Missing the first appointment, Penultimate day of every month, Two hours every day, Extended Guile examples
  391. @subsection Missing the first appointment
  392. @cindex examples, missing the first appointment
  393. @cindex pitfalls, missing the first appointment
  394. The command
  395. @example
  396. (job '(next-hour-from (next-day) '(16))
  397. "my-program")
  398. @end example
  399. will run @code{my-program} every day at four o'clock in the
  400. afternoon. However, if mcron is started with this script at midday,
  401. the first time the command will run will be four o'clock tomorrow;
  402. today's appointment will be missed (one time only).
  403. The correct way to specify this requirement is simply
  404. @example
  405. (job '(next-hour '(16))
  406. "my-program")
  407. @end example
  408. @node Penultimate day of every month, , Missing the first appointment, Extended Guile examples
  409. @subsection Penultimate day of every month
  410. @cindex examples, penultimate day of every month
  411. The following will run the @code{my-program} program on the
  412. second-to-last day of every month.
  413. @example
  414. (job '(- (next-month-from (next-month)) (* 48 3600))
  415. "my-program")
  416. @end example
  417. @node Vixie Syntax, , Extended Guile examples, Syntax
  418. @section Vixie
  419. @cindex syntax, vixie
  420. @cindex vixie syntax
  421. @cindex vixie definition
  422. @cindex vixie compatibility
  423. @cindex compatibility, vixie
  424. @emph{NOTE} that this section is definitive. If there is a difference in
  425. behaviour between the mcron program and this part of the manual, then
  426. there is a bug in the program. This section is also copied verbatim
  427. from Paul Vixie's documentation for his cron program, and his
  428. copyright notice is duly reproduced below.
  429. There are three problems with this specification.
  430. @cindex zero'th day of month
  431. @cindex 0'th day of month
  432. 1. It is allowed to specify days of the month in the range 0-31. What
  433. does it mean to specify day 0? Looking at the Vixie source code, it
  434. seems that if this date appears as part of a list, it has no
  435. effect. However, if it appears on its own, the effect is to say
  436. ``don't run on any particular day of the month, only take the week-day
  437. specification into account.'' Mcron has been coded to mimic this
  438. behaviour as a special case (unmodified mcron logic implies that this
  439. date specification would cause jobs to run on the last day of the
  440. previous month).
  441. @cindex thirteenth month of year
  442. @cindex 13th month of year
  443. 2. Similarly to the above (but different), months of the year can be
  444. specified in the range 0-12. In the case of mcron (don't know what
  445. Vixie cron did) month 12 will cause the program to wait until January
  446. of the following year (but don't rely on this).
  447. @cindex shell
  448. @cindex environment variables, shell
  449. @cindex /etc/passwd
  450. 3. Somewhere it says that cron sets the SHELL environment variable to
  451. /bin/sh, and elsewhere it implies that the default behaviour is for
  452. the user's default shell to be used to execute commands. Mcron sets
  453. the variable and runs the command in the user's default shell, as
  454. advertised by the /etc/passwd file.
  455. @menu
  456. * Paul Vixie's copyright::
  457. * Crontab file::
  458. * Incompatibilities with old Unices::
  459. @end menu
  460. @node Paul Vixie's copyright, Crontab file, Vixie Syntax, Vixie Syntax
  461. @subsection Paul Vixie's copyright
  462. @cindex copyright, Paul Vixie's
  463. @cindex Paul Vixie's copyright
  464. @quotation
  465. Copyright 1988,1990,1993,1994 by Paul Vixie
  466. All rights reserved
  467. Distribute freely, except: don't remove my name from the source or
  468. documentation (don't take credit for my work), mark your changes (don't
  469. get me blamed for your possible bugs), don't alter or remove this
  470. notice. May be sold if buildable source is provided to buyer. No
  471. warrantee of any kind, express or implied, is included with this
  472. software; use at your own risk, responsibility for damages (if any) to
  473. anyone resulting from the use of this software rests entirely with the
  474. user.
  475. @end quotation
  476. @node Crontab file, Incompatibilities with old Unices, Paul Vixie's copyright, Vixie Syntax
  477. @subsection Crontab files
  478. @cindex crontab file
  479. @cindex vixie crontab file
  480. A @code{crontab} file contains instructions to the @code{cron} daemon
  481. of the general form: ``run this command at this time on this date''.
  482. Each user has their own crontab, and commands in any given crontab
  483. will be executed as the user who owns the crontab. Uucp and News will
  484. usually have their own crontabs, eliminating the need for explicitly
  485. running @code{su} as part of a cron command.
  486. @cindex comments, vixie-style
  487. Blank lines and leading spaces and tabs are ignored. Lines whose first
  488. non-space character is a pound-sign (#) are comments, and are ignored.
  489. Note that comments are not allowed on the same line as cron commands, since
  490. they will be taken to be part of the command. Similarly, comments are not
  491. allowed on the same line as environment variable settings.
  492. An active line in a crontab will be either an environment setting or a cron
  493. command. An environment setting is of the form,
  494. @cindex environment setting, vixie-style
  495. @example
  496. name = value
  497. @end example
  498. where the spaces around the equal-sign (=) are optional, and any
  499. subsequent non-leading spaces in @code{value} will be part of the
  500. value assigned to @code{name}. The @code{value} string may be placed
  501. in quotes (single or double, but matching) to preserve leading or
  502. trailing blanks.
  503. @cindex environment variables, SHELL
  504. @cindex environment variables, LOGNAME
  505. @cindex environment variables, HOME
  506. @cindex SHELL environment variable
  507. @cindex LOGNAME environment variable
  508. @cindex HOME environment variable
  509. @cindex /etc/passwd
  510. Several environment variables are set up automatically by the
  511. @code{cron} daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are
  512. set from the /etc/passwd line of the crontab's owner. HOME and SHELL
  513. may be overridden by settings in the crontab; LOGNAME may not.
  514. @cindex environment variables, USER
  515. @cindex USER environment variable
  516. @cindex BSD
  517. (Another note: the LOGNAME variable is sometimes called USER on BSD systems...
  518. on these systems, USER will be set also.) @footnote{mcron has not been
  519. ported to BSD, so these notes are not relevant.}
  520. @cindex environment variables, MAILTO
  521. @cindex MAILTO environment variable
  522. In addition to LOGNAME, HOME, and SHELL, @code{cron} will look at
  523. MAILTO if it has any reason to send mail as a result of running
  524. commands in ``this'' crontab. If MAILTO is defined (and non-empty),
  525. mail is sent to the user so named. If MAILTO is defined but empty
  526. (MAILTO=""), no mail will be sent. Otherwise mail is sent to the
  527. owner of the crontab. This option is useful if you decide on
  528. /bin/mail instead of /usr/lib/sendmail as your mailer when you install
  529. cron -- /bin/mail doesn't do aliasing, and UUCP usually doesn't read
  530. its mail.
  531. The format of a cron command is very much the V7 standard, with a number of
  532. upward-compatible extensions. Each line has five time and date fields,
  533. followed by a user name if this is the system crontab file,
  534. followed by a command. Commands are executed by @code{cron}
  535. when the minute, hour, and month of year fields match the current
  536. time, @strong{and} when at least one of the two day fields (day of month, or day of week)
  537. match the current time (see ``Note'' below). @code{cron} examines cron entries once every minute.
  538. The time and date fields are:
  539. @cindex vixie time specification fields
  540. @cindex fields, vixie time specification
  541. @multitable @columnfractions .2 .5
  542. @item Field @tab Allowed values
  543. @item ----- @tab --------------
  544. @item minute @tab 0-59
  545. @item hour @tab 0-23
  546. @item day of month @tab 0-31
  547. @item month @tab 0-12 (or names, see below)
  548. @item day of week @tab 0-7 (0 or 7 is Sun, or use names)
  549. @end multitable
  550. A field may be an asterisk (*), which always stands for ``first-last''.
  551. @cindex ranges in vixie time specifications
  552. Ranges of numbers are allowed. Ranges are two numbers separated
  553. with a hyphen. The specified range is inclusive. For example,
  554. 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
  555. and 11.
  556. @cindex lists in vixie time specifications
  557. Lists are allowed. A list is a set of numbers (or ranges)
  558. separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''.
  559. @cindex steps in vixie time specifications
  560. Step values can be used in conjunction with ranges. Following
  561. a range with ``/<number>'' specifies skips of the number's value
  562. through the range. For example, ``0-23/2'' can be used in the hours
  563. field to specify command execution every other hour (the alternative
  564. in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are
  565. also permitted after an asterisk, so if you want to say ``every two
  566. hours'', just use ``*/2''.
  567. @cindex names in vixie-style time specifications
  568. Names can also be used for the ``month'' and ``day of week''
  569. fields. Use the first three letters of the particular
  570. day or month (case doesn't matter). Ranges or
  571. lists of names are not allowed. @footnote{Mcron allows any alphabetic
  572. characters after a name, so full names of days or months are also valid.}
  573. @cindex % character on vixie-style commands
  574. @cindex standard input, vixie-style
  575. The ``sixth'' field (the rest of the line) specifies the command to be
  576. run.
  577. The entire command portion of the line, up to a newline or %
  578. character, will be executed by /bin/sh or by the shell
  579. specified in the SHELL variable of the cronfile.
  580. Percent-signs (%) in the command, unless escaped with backslash
  581. (\\), will be changed into newline characters, and all data
  582. after the first % will be sent to the command as standard
  583. input.
  584. @cindex day specification, vixie-style
  585. @cindex vixie-style day specification
  586. Note: The day of a command's execution can be specified by two
  587. fields -- day of month, and day of week. If both fields are
  588. restricted (ie, aren't *), the command will be run when
  589. @emph{either}
  590. field matches the current time. For example,
  591. ``30 4 1,15 * 5''
  592. would cause a command to be run at 4:30 am on the 1st and 15th of each
  593. month, plus every Friday.
  594. EXAMPLE CRON FILE
  595. @example
  596. # use /bin/sh to run commands, no matter what /etc/passwd says
  597. SHELL=/bin/sh
  598. # mail any output to `paul', no matter whose crontab this is
  599. MAILTO=paul
  600. #
  601. # run five minutes after midnight, every day
  602. 5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
  603. # run at 2:15pm on the first of every month -- output mailed to paul
  604. 15 14 1 * * $HOME/bin/monthly
  605. # run at 10 pm on weekdays, annoy Joe
  606. 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
  607. 23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
  608. 5 4 * * sun echo "run at 5 after 4 every sunday"
  609. @end example
  610. @node Incompatibilities with old Unices, , Crontab file, Vixie Syntax
  611. @subsection Extensions and incompatibilities
  612. @cindex incompatibilities with old Unices
  613. @cindex extensions, vixie over old Unices
  614. This section lists differences between Paul Vixie's cron and the
  615. olde-worlde BSD and AT&T programs, for the benefit of system
  616. administrators and users who are upgrading all the way.
  617. @itemize @bullet
  618. @item
  619. @cindex day 7
  620. When specifying day of week, both day 0 and day 7 will be considered Sunday.
  621. BSD and AT&T seem to disagree about this.
  622. @item
  623. Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would
  624. be rejected by AT&T or BSD cron -- they want to see "1-3" or "7,8,9" ONLY.
  625. @item
  626. Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".
  627. @item
  628. Names of months or days of the week can be specified by name.
  629. @item
  630. Environment variables can be set in the crontab. In BSD or AT&T, the
  631. environment handed to child processes is basically the one from /etc/rc.
  632. @item
  633. Command output is mailed to the crontab owner (BSD can't do this), can be
  634. mailed to a person other than the crontab owner (SysV can't do this), or the
  635. feature can be turned off and no mail will be sent at all (SysV can't do this
  636. either).
  637. @end itemize
  638. @node Invoking, Guile modules, Syntax, Top
  639. @chapter Detailed invoking
  640. @cindex invoking
  641. @cindex personality
  642. @cindex mcron program
  643. @cindex cron program
  644. @cindex crond program
  645. @cindex crontab program
  646. The program adopts one of three different personalities depending on
  647. the name used to invoke it. In a standard installation, the program is
  648. installed in the system under the names mcron, cron and crontab
  649. (installed SUID).
  650. The recommended way to invoke the program is via the mcron personality
  651. described in the next section. The program can also be run as cron by
  652. root, and by the SUID program crontab by individual users to gain
  653. backwards compatibility with Vixie cron. However, due to the fact that
  654. this daemon process is shared by, and under control of, all the users
  655. of the system it is possible (though very unlikely) that it may become
  656. unusable, hence the recommendation to use the mcron personality.
  657. @cindex deprecated, vixie personality
  658. Furthermore, the Vixie personality is considered deprecated by this
  659. author (it offers not a single advantage over the mcron personality,
  660. and bloats the code by a factor of three). It is unlikely that this
  661. personality will ever actually go away, but the program may in future
  662. be split into two distinct parts, and new developments will only take
  663. place in the part which implements the mcron personality.
  664. @menu
  665. * Invoking mcron::
  666. * Invoking cron or crond::
  667. * Invoking crontab::
  668. * Behaviour on laptops::
  669. * Exit codes::
  670. @end menu
  671. @node Invoking mcron, Invoking cron or crond, Invoking, Invoking
  672. @section Invoking mcron
  673. @cindex invoking mcron
  674. @cindex mcron options
  675. @cindex mcron arguments
  676. @cindex command line, mcron
  677. @cindex mcron command line
  678. Mcron should be run by the user who wants to schedule his jobs. It
  679. may be made a background job using the facilities of the shell. The
  680. basic command is @code{mcron [OPTION ...] [file ...]} which has the
  681. effect of reading all the configuration files specified (subject to
  682. the options) and then waiting until it is time to execute some
  683. command. If no files are given on the command line, then mcron will
  684. look in the user's cron configuration directories: these are ~/.cron
  685. (deprecated), the directory indicated by the @code{XDG_CONFIG_HOME}
  686. environment variable, or ~/.config/cron if this variable is not set.
  687. In any case, files which end in the extension .vixie or .vix will be
  688. assumed to contain Vixie-style crontabs, and files ending .guile or
  689. .gle will be assumed to contain scheme code and will be executed as
  690. such; ANY OTHER FILES WILL BE IGNORED - specify a file name of ``-''
  691. and then pipe the files into the standard input if you really want to
  692. read them, possibly using the @code{stdin} option to specify the type
  693. of file.
  694. The program accepts the following options.
  695. @table @option
  696. @item -s count
  697. @itemx --schedule=count
  698. @cindex printout of jobs schedule
  699. @cindex schedule of jobs, listing
  700. @cindex options, schedule
  701. @cindex options, -s
  702. @cindex -s option
  703. @cindex --schedule option
  704. With this option specified no commands are run. Instead, the program
  705. computes the times the commands would be run and prints the
  706. information to the screen, and then immediately exits.
  707. The count indicates the number of commands to display.
  708. @cindex daemon option
  709. @cindex options, daemon
  710. @cindex options, -d
  711. @cindex -d option
  712. @cindex --daemon option
  713. @item -d
  714. @itemx --daemon
  715. With this option the program will detach itself from the controlling
  716. terminal and run as a daemon process.
  717. @cindex stdin option
  718. @cindex options, stdin
  719. @cindex options, -i
  720. @cindex -i option
  721. @cindex --stdin option
  722. @cindex standard input, configuring from
  723. @cindex configuring from standard input
  724. @item -i (vixie|guile)
  725. @itemx --stdin=(vixie|guile)
  726. This option is used to indicate whether the configuration information
  727. being passed on the standard input is in Vixie format or Guile
  728. format. Guile is the default.
  729. @cindex -v option
  730. @cindex --version option
  731. @cindex options, -v
  732. @cindex options, version
  733. @item -v
  734. @itemx --version
  735. This option causes a message to be printed on the standard output with
  736. information about the version and copyright for the current program.
  737. @cindex -h option
  738. @cindex --help option
  739. @cindex options, -h
  740. @cindex options, --help
  741. @item -h
  742. @itemx --help
  743. This causes a short but complete usage message to be displayed on
  744. standard output.
  745. @end table
  746. @node Invoking cron or crond, Invoking crontab, Invoking mcron, Invoking
  747. @section Invoking cron or crond
  748. @cindex cron, invokation
  749. @cindex invoking cron
  750. @cindex crond, invokation
  751. @cindex invoking crond
  752. @cindex @value{CONFIG_SPOOL_DIR}
  753. @cindex @value{CONFIG_SOCKET_FILE}
  754. NOTE THAT THIS SECTION ONLY APPLIES IF THE @code{cron} or
  755. @code{crond}, and @code{crontab} PROGRAMS HAVE BEEN INSTALLED BY THE
  756. SYSTEM ADMINISTRATOR.
  757. If the program runs by the name of @code{cron} or @code{crond}, then
  758. it will read all the files in @code{@value{CONFIG_SPOOL_DIR}} (which
  759. should only be readable by root) and the file @code{/etc/crontab}, and
  760. then detaches itself from the terminal to live forever as a daemon
  761. process. Additionally, it creates a UNIX socket at
  762. @code{@value{CONFIG_SOCKET_FILE}}, and listens for messages sent to
  763. that socket consisting of a user name whose crontabs have been
  764. changed. In this case, the program will re-read that user's crontab.
  765. This is for correct functioning with the crontab program.
  766. Further, if the @code{--noetc} option was not used, a job is scheduled
  767. to run every minute to check if /etc/crontab has been modified
  768. recently. If so, this file will also be re-read.
  769. The options which may be used with this program are as follows.
  770. @table @option
  771. @cindex -v option
  772. @cindex --version option
  773. @cindex options, -v
  774. @cindex options, version
  775. @item -v
  776. @itemx --version
  777. This option causes a message to be printed on the standard output with
  778. information about the version and copyright for the current program.
  779. @cindex -h option
  780. @cindex --help option
  781. @cindex options, -h
  782. @cindex options, --help
  783. @item -h
  784. @itemx --help
  785. This causes a short but complete usage message to be displayed on
  786. standard output.
  787. @item -s [count]
  788. @itemx --schedule[=count]
  789. @cindex printout of jobs schedule
  790. @cindex schedule of jobs, listing
  791. @cindex options, schedule
  792. @cindex options, -s
  793. @cindex -s option
  794. @cindex --schedule option
  795. With this option specified no commands are run. Instead, the program
  796. computes the times the commands would be run and prints the
  797. information to the screen, and then immediately exits.
  798. The count, if supplied, indicates the number of commands to
  799. display. The default value is 8.
  800. @cindex -n option
  801. @cindex --noetc option
  802. @cindex options, -n
  803. @cindex options, --noetc
  804. @item -n
  805. @itemx --noetc
  806. This tells cron not to add a job to the system which wakes up every
  807. minute to check for modifications to @code{/etc/crontab}. It is
  808. recommended that this option be used (and further that the
  809. @code{/etc/crontab} file be taken off the system altogether!)
  810. @end table
  811. @node Invoking crontab, Behaviour on laptops, Invoking cron or crond, Invoking
  812. @section Invoking crontab
  813. @cindex crontab, invoking
  814. @cindex invoking crontab
  815. This program is run by individual users to inspect or modify their
  816. crontab files. If a change is made to the file, then the root daemon
  817. process will be given a kick, and will immediately read the new
  818. configuration. A warning will be issued to standard output if it
  819. appears that a cron daemon is not running.
  820. The command is used as
  821. @code{crontab [-u user] file}
  822. or
  823. @code{crontab [-u user] ( -l | -e | -r )}
  824. Only the root user can use the -u option, to specify the manipulation
  825. of another user's crontab file. In the first instance, the entire
  826. crontab file of the user is replaced with the contents of the
  827. specified file, or standard input if the file is ``-''.
  828. In the latter case, the program behaves according to which of the
  829. (mutually exclusive) options was given (note that the long options are
  830. an mcron extension).
  831. @table @option
  832. @cindex -l option
  833. @cindex list option, crontab
  834. @cindex options, -l
  835. @cindex options, --list
  836. @cindex viewing a crontab
  837. @cindex listing a crontab
  838. @item -l
  839. @itemx --list
  840. Print the user's crontab file to the standard output, and exit.
  841. @cindex -r option
  842. @cindex remove option
  843. @cindex options, -r
  844. @cindex options, --remove
  845. @cindex deleting a crontab
  846. @cindex removing a crontab
  847. @item -r
  848. @item --remove
  849. Delete the user's crontab file, and exit.
  850. @cindex -e option
  851. @cindex edit option
  852. @cindex options, -e
  853. @cindex options, --edit
  854. @cindex editing a crontab
  855. @cindex creating a crontab
  856. @item -e
  857. @item --edit
  858. Using the editor specified in the user's VISUAL or EDITOR environment
  859. variables, allow the user to edit his crontab. Once the user exits the
  860. editor, the crontab is checked for parseability, and if it is okay
  861. then it is installed as the user's new crontab and the daemon is
  862. notified that a change has taken place, so that the new file will
  863. become immediately effective.
  864. @end table
  865. @node Behaviour on laptops, Exit codes, Invoking crontab, Invoking
  866. @section Behaviour on laptops
  867. @cindex laptops
  868. @cindex power suspend
  869. While mcron has not been designed to work anachronistically, the behaviour of
  870. mcron when a laptop emerges from a suspended state is well defined, and the
  871. following description explains what happens in this situation.
  872. When a laptop awakes from a suspended state, all jobs which would have run while
  873. the laptop was suspended will run exactly once immediately (and simultaneously)
  874. when the laptop awakes, and then the next time that those jobs run will be
  875. computed based on the time the laptop was awoken. Any jobs which would not have
  876. run during the suspense period will be unaffected, and will still run at their
  877. proper times.
  878. @node Exit codes, , Behaviour on laptops, Invoking
  879. @section Exit codes
  880. @cindex exit codes
  881. @cindex error conditions
  882. @cindex errors
  883. The following are the status codes returned to the operating system
  884. when the program terminates.
  885. @table @asis
  886. @item 0
  887. No problems.
  888. @item 1
  889. An attempt has been made to start cron but there is already a
  890. @value{CONFIG_PID_FILE} file. If there really is no other cron daemon
  891. running (this does not include invokations of mcron) then you should
  892. remove this file before attempting to run cron.
  893. @item 2
  894. In parsing a guile configuration file, a @code{job} command has been
  895. seen but the second argument is neither a procedure, list or
  896. string. This argument is the job's action, and needs to be specified
  897. in one of these forms.
  898. @item 3
  899. In parsing a guile configuration file, a @code{job} command has been
  900. seen but the first argument is neither a procedure, list or
  901. string. This argument is the job's next-time specification, and needs
  902. to be specified in one of these forms.
  903. @item 4
  904. An attempt to run cron has been made by a user who does not have
  905. permission to access the crontabs in @value{CONFIG_SPOOL_DIR}. These
  906. files should be readable only by root, and the cron daemon must be run
  907. as root.
  908. @item 5
  909. An attempt to run mcron has been made, but there are no jobs to
  910. schedule!
  911. @item 6
  912. The system administrator has blocked this user from using crontab with
  913. the files @value{CONFIG_ALLOW_FILE} and @value{CONFIG_DENY_FILE}.
  914. @item 7
  915. Crontab has been run with more than one of the arguments @code{-l},
  916. @code{-r}, @code{-e}. These are mutually exclusive options.
  917. @item 8
  918. Crontab has been run with the -u option by a user other than
  919. root. Only root is allowed to use this option.
  920. @item 9
  921. An invalid vixie-style time specification has been supplied.
  922. @item 10
  923. An invalid vixie-style job specification has been supplied.
  924. @item 11
  925. A bad line has been seen in /etc/crontab.
  926. @item 12
  927. The last component of the name of the program was not one of
  928. @code{mcron}, @code{cron}, @code{crond} or @code{crontab}.
  929. @item 13
  930. Either none of the user's configuration directories exist, or there is a problem
  931. reading the files there. The configuration directories are ~/.cron
  932. and the directory pointed to by the @code{XDG_CONFIG_HOME} environment
  933. variable, or ~/.config/cron if this is not set.
  934. @c @item 14
  935. @c There is a problem writing to /var/cron/update. This is probably
  936. @c because the crontab program is not installed SUID root, as it should
  937. @c be.
  938. @item 15
  939. Crontab has been run without any arguments at all. There is no default
  940. behaviour in this case.
  941. @item 16
  942. Cron has been run by a user other than root.
  943. @end table
  944. @node Guile modules, Index, Invoking, Top
  945. @chapter Guile modules
  946. Some of the key parts of mcron are implemented as modules so they can
  947. be incorporated into other Guile programs, or even into C-sourced
  948. programs if they are linked against libguile.
  949. It may be, for example, that a program needs to perform house-keeping
  950. functions at certain times of the day, in which case it can spawn
  951. (either fork or thread) a sub-process which uses a built-in
  952. mcron. Another example may be a program which must sleep until some
  953. non-absolute time specified on the Gregorian calendar (the first day
  954. of next week, for example). Finally, it may be the wish of the user to
  955. provide a program with the functionality of mcron plus a bit extra.
  956. The base module maintains mcron's internal job lists, and provides the
  957. main wait-run-wait loop that is mcron's main function. It also
  958. introduces the facilities for accumulating a set of environment
  959. modifiers, which take effect when jobs run.
  960. @menu
  961. * The base module:: The job list and execution loop.
  962. * The redirect module:: Sending output of jobs to a mail box.
  963. * The vixie-time module:: Parsing vixie-style time specifications.
  964. * The job-specifier module:: All commands for scheme configuration files.
  965. * The vixie-specification module:: Commands for reading vixie-style crontabs.
  966. @end menu
  967. @node The base module, The redirect module, Guile modules, Guile modules
  968. @section The base module
  969. @cindex guile module
  970. @cindex base module
  971. @cindex modules, base
  972. This module may be used by including @code{(use-modules (mcron base))}
  973. in a program. The main functions are @code{add-job} and
  974. @code{run-job-loop}, which allow a program to create a list of job
  975. specifications to run, and then to initiate the wait-run-wait loop
  976. firing the jobs off at the requisite times. However, before they are
  977. introduced two functions which manipulate the environment that takes
  978. effect when a job runs are defined.
  979. @cindex environment
  980. The environment is a set of name-value pairs which is built up
  981. incrementally. Each time the @code{add-job} function is called, the
  982. environment modifiers that have been accumulated up to that point are
  983. stored with the new job specification, and when the job actually runs
  984. these name-value pairs are used to modify the run-time environment in
  985. effect.
  986. @deffn{Scheme procedure} append-environment-mods name value
  987. When a job is run make sure the environment variable @var{name} has
  988. the value @var{value}.
  989. @end deffn
  990. @deffn{Scheme procedure} clear-environment-mods
  991. This procedure causes all the environment modifiers that have been
  992. specified so far to be forgotten.
  993. @end deffn
  994. @deffn{Scheme procedure} add-job time-proc action displayable configuration-time configuration-user
  995. This procedure adds a job specification to the list of all jobs to
  996. run. @var{time-proc} should be a procedure taking exactly one argument
  997. which will be a UNIX time. This procedure must compute the next time
  998. that the job should run, and return the result. @var{action} should be
  999. a procedure taking no arguments, and contains the instructions that
  1000. actually get executed whenever the job is scheduled to
  1001. run. @var{displayable} should be a string, and is only for the use of
  1002. humans; it can be anything which identifies or simply gives a clue as
  1003. to the purpose or function of this job. @var{configuration-time} is
  1004. the time from which the first invokation of this job should be
  1005. computed. Finally, @var{configuration-user} should be the passwd entry
  1006. for the user under whose personality the job is to run.
  1007. @end deffn
  1008. @deffn{Scheme procedure} run-job-loop . fd-list
  1009. @cindex file descriptors
  1010. @cindex interrupting the mcron loop
  1011. This procedure returns only under exceptional circumstances, but
  1012. usually loops forever waiting for the next time to arrive when a job
  1013. needs to run, running that job, recomputing the next run time, and
  1014. then waiting again. However, the wait can be interrupted by data
  1015. becoming available for reading on one of the file descriptors in the
  1016. fd-list, if supplied. Only in this case will the procedure return to
  1017. the calling program, which may then make modifications to the job list
  1018. before calling the @code{run-job-loop} procedure again to resume execution of
  1019. the mcron base.
  1020. @end deffn
  1021. @deffn{Scheme procedure} remove-user-jobs user
  1022. The argument @var{user} should be a string naming a user (his
  1023. login name), or an integer UID, or an object representing the user's passwd
  1024. entry. All jobs on the current job list that are scheduled to be run
  1025. under this personality are removed from the job list.
  1026. @end deffn
  1027. @deffn{Scheme procedure} get-schedule count
  1028. @cindex schedule of jobs
  1029. The argument @var{count} should be an integer value giving the number
  1030. of time-points in the future to report that jobs will run as. Note
  1031. that this procedure is disruptive; if @code{run-job-loop} is called
  1032. after this procedure, the first job to run will be the one after the
  1033. last job that was reported in the schedule report. The report itself
  1034. is returned to the calling program as a string.
  1035. @end deffn
  1036. @node The redirect module, The vixie-time module, The base module, Guile modules
  1037. @section The redirect module
  1038. @cindex redirect module
  1039. @cindex modules, redirect
  1040. This module is introduced to a program with the command
  1041. @code{(use-modules (mcron redirect))}.
  1042. This module provides the @code{with-mail-out} function, described
  1043. fully in @ref{Guile Syntax}.
  1044. @node The vixie-time module, The job-specifier module, The redirect module, Guile modules
  1045. @section The vixie-time module
  1046. @cindex vixie-time module
  1047. @cindex modules, vixie-time
  1048. This module is introduced to a program by @code{(use-modules (mcron
  1049. vixie-time))}.
  1050. This module provides a single method for converting a vixie-style time
  1051. specification into a procedure which can be used as the
  1052. @code{next-time-function} to the base @code{add-job} procedure, or to
  1053. the @code{job-specifier} @code{job} procedure. See @ref{Vixie Syntax}
  1054. for full details of the allowed format for the time string.
  1055. @deffn{Scheme procedure} parse-vixie-time time-string
  1056. The single argument @var{time-string} should be a string containing a
  1057. vixie-style time specification, and the return value is the required
  1058. procedure.
  1059. @end deffn
  1060. @node The job-specifier module, The vixie-specification module, The vixie-time module, Guile modules
  1061. @section The job-specifier module
  1062. @cindex job-specifier module
  1063. @cindex modules, job-specifier
  1064. This module is introduced to a program by @code{(use-modules (mcron
  1065. job-specifier))}.
  1066. This module provides all the functions available to user's Guile
  1067. configuration files, namely @code{range}, @code{next-year-from},
  1068. @code{next-year}, @code{next-month-from}, @code{next-month},
  1069. @code{next-day-from}, @code{next-day}, @code{next-hour-from},
  1070. @code{next-hour}, @code{next-minute-from}, @code{next-minute},
  1071. @code{next-second-from}, @code{next-second},
  1072. and last but not least, @code{job}. See @ref{Guile Syntax} for full
  1073. details.
  1074. Once this module is loaded, a scheme configuration file can be used to
  1075. put jobs onto the job list simply by @code{load}ing the file.
  1076. @node The vixie-specification module, , The job-specifier module, Guile modules
  1077. @section The vixie-specification module
  1078. @cindex vixie-specification module
  1079. @cindex modules, vixie-specification
  1080. To use this module, put the command @code{(use-modules (mcron
  1081. vixie-specification))} into your program.
  1082. This module exports a couple of functions for adding jobs to the
  1083. internal job list according to a Vixie-style crontab file.
  1084. @deffn{Scheme procedure} read-vixie-port port . parse-line
  1085. This procedure reads a crontab from the given port, and adds jobs to
  1086. the job list accordingly, taking care of environment specifications
  1087. and comments which may appear in such a file.
  1088. @var{parse-line} should not normally be used, except that if you are
  1089. parsing a (deprecated) @code{/etc/crontab} file with a slightly
  1090. modified syntax, you may pass the value @var{parse-system-vixie-line}
  1091. as the optional argument.
  1092. @end deffn
  1093. @deffn{Scheme procedure} read-vixie-file name . parse-line
  1094. This procedure attempts to open the named file, and if it fails will
  1095. return silently. Otherwise, the behaviour is identical to
  1096. @code{read-vixie-port} above.
  1097. @end deffn
  1098. Once this module has been declared in a program, a crontab file can be
  1099. used to augment the current job list with a call to
  1100. @code{read-vixie-file}.
  1101. @node GNU Free Documentation License
  1102. @appendix GNU Free Documentation License
  1103. @include fdl.texi
  1104. @node Index, , Guile modules, Top
  1105. @unnumbered Index
  1106. @printindex cp
  1107. @bye