Cron

Parses /etc/cron.d/*, /etc/crontab

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
CronParses /etc/cron.d/*, /etc/crontab
ReferenceThis lens tries to keep as close as possible to `man 5 crontab` where possible.
LicenseThis file is licensed under the LGPL v2+, like the rest of Augeas.
Lens UsageSample usage of this lens in augtool
Configuration filesThis lens applies to /etc/cron.d/* and /etc/crontab.
USEFUL PRIMITIVES
Generic primitives
eol
indent
comment
empty
num
alpha
alphanum
entry_prefix
Separators
sep_spc
sep_eq
ENTRIES
shellvarA shell variable in crontab
- prefix of an entry
minute
hour
dayofmonth
month
dayofweek
user
timeTime in the format “minute hour dayofmonth month dayofweek”
the valid values for schedules
scheduleTime in the format “@keyword”
entryA crontab entry
lnsThe cron lens
filter

Reference

This lens tries to keep as close as possible to `man 5 crontab` where possible.

License

This file is licensed under the LGPL v2+, like the rest of Augeas.

Lens Usage

Sample usage of this lens in augtool

  • Get the entry that launches ‘/usr/bin/ls’
match '/files/etc/crontab/entry[. = "/usr/bin/ls"]'

Configuration files

This lens applies to /etc/cron.d/* and /etc/crontab.  See filter.

USEFUL PRIMITIVES

Generic primitives

eol

let eol = Util.eol

indent

let indent = Util.indent

comment

let comment = Util.comment

empty

let empty = Util.empty

num

let num = /[0-9*][0-9\/,*-]*/

alpha

let alpha = /[A-Za-z]{3}/

alphanum

let alphanum = (num|alpha) . ("-" . (num|alpha))?

entry_prefix

let entry_prefix = /-/

Separators

sep_spc

let sep_spc = Util.del_ws_spc

sep_eq

let sep_eq = Util.del_str "="

ENTRIES

shellvar

let shellvar = let key_re = /[A-Za-z1-9_-]+(\[[0-9]+\])?/ - "entry" in let sto_to_eol = store /[^\n]*[^ \t\n]/ in [ key key_re . sep_eq . sto_to_eol . eol ]

A shell variable in crontab

- prefix of an entry

minute

let minute = [ label "minute" . store num ]

hour

let hour = [ label "hour" . store num ]

dayofmonth

let dayofmonth = [ label "dayofmonth" . store num ]

month

let month = [ label "month" . store alphanum ]

dayofweek

let dayofweek = [ label "dayofweek" . store alphanum ]

user

let user = [ label "user" . store Rx.word ]

time

let time = [ label "time" . minute . sep_spc . hour . sep_spc . dayofmonth . sep_spc . month . sep_spc . dayofweek ]

Time in the format “minute hour dayofmonth month dayofweek”

the valid values for schedules

schedule

let schedule = [ label "schedule" . Util.del_str "@" . store schedule_re ]

Time in the format “@keyword”

entry

let entry = [ label "entry" . indent . prefix? . ( time | schedule ) . sep_spc . user . sep_spc . store Rx.space_in . eol ]

A crontab entry

lns

let lns = ( empty | comment | shellvar | entry )*

The cron lens

filter

let eol = Util.eol
let indent = Util.indent
let comment = Util.comment
let empty = Util.empty
let num = /[0-9*][0-9\/,*-]*/
let alpha = /[A-Za-z]{3}/
let alphanum = (num|alpha) . ("-" . (num|alpha))?
let entry_prefix = /-/
let sep_spc = Util.del_ws_spc
let sep_eq = Util.del_str "="
let shellvar = let key_re = /[A-Za-z1-9_-]+(\[[0-9]+\])?/ - "entry" in let sto_to_eol = store /[^\n]*[^ \t\n]/ in [ key key_re . sep_eq . sto_to_eol . eol ]
A shell variable in crontab
let minute = [ label "minute" . store num ]
let hour = [ label "hour" . store num ]
let dayofmonth = [ label "dayofmonth" . store num ]
let month = [ label "month" . store alphanum ]
let dayofweek = [ label "dayofweek" . store alphanum ]
let user = [ label "user" . store Rx.word ]
let time = [ label "time" . minute . sep_spc . hour . sep_spc . dayofmonth . sep_spc . month . sep_spc . dayofweek ]
Time in the format “minute hour dayofmonth month dayofweek”
let schedule = [ label "schedule" . Util.del_str "@" . store schedule_re ]
Time in the format “@keyword”
let entry = [ label "entry" . indent . prefix? . ( time | schedule ) . sep_spc . user . sep_spc . store Rx.space_in . eol ]
A crontab entry
let lns = ( empty | comment | shellvar | entry )*
The cron lens
Close