2020-07-30 16:20:24 -07:00
|
|
|
|
2020-02-04 14:19:33 -08:00
|
|
|
# jc.parsers.crontab_u
|
|
|
|
jc - JSON CLI output utility crontab file Parser
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified
|
|
|
|
|
|
|
|
Compatibility:
|
|
|
|
|
|
|
|
'linux', 'darwin', 'aix', 'freebsd'
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2020-02-08 12:46:14 -08:00
|
|
|
$ cat /etc/crontab | jc --crontab-u -p
|
2020-02-04 14:19:33 -08:00
|
|
|
{
|
|
|
|
"variables": [
|
|
|
|
{
|
|
|
|
"name": "PATH",
|
|
|
|
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "SHELL",
|
|
|
|
"value": "/bin/sh"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"schedule": [
|
|
|
|
{
|
|
|
|
"minute": [
|
|
|
|
"25"
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
"6"
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": [
|
|
|
|
"47"
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
"6"
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
"7"
|
|
|
|
],
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": [
|
|
|
|
"52"
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
"6"
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
"1"
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
$ cat /etc/crontab | jc --crontab-u -p -r
|
|
|
|
{
|
|
|
|
"variables": [
|
|
|
|
{
|
|
|
|
"name": "PATH",
|
|
|
|
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "SHELL",
|
|
|
|
"value": "/bin/sh"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"schedule": [
|
|
|
|
{
|
|
|
|
"minute": "25",
|
|
|
|
"hour": "6",
|
|
|
|
"day_of_month": "*",
|
|
|
|
"month": "*",
|
|
|
|
"day_of_week": "*",
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": "47",
|
|
|
|
"hour": "6",
|
|
|
|
"day_of_month": "*",
|
|
|
|
"month": "*",
|
|
|
|
"day_of_week": "7",
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": "52",
|
|
|
|
"hour": "6",
|
|
|
|
"day_of_month": "1",
|
|
|
|
"month": "*",
|
|
|
|
"day_of_week": "*",
|
|
|
|
"user": "root",
|
|
|
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2020-02-04 14:19:33 -08:00
|
|
|
## info
|
|
|
|
```python
|
2020-07-30 16:20:24 -07:00
|
|
|
info()
|
2020-02-04 14:19:33 -08:00
|
|
|
```
|
|
|
|
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2020-02-04 14:19:33 -08:00
|
|
|
## process
|
|
|
|
```python
|
|
|
|
process(proc_data)
|
|
|
|
```
|
|
|
|
|
|
|
|
Final processing to conform to the schema.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
proc_data: (dictionary) raw structured data to process
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
Dictionary. Structured data with the following schema:
|
|
|
|
|
|
|
|
{
|
|
|
|
"variables": [
|
|
|
|
"name": string,
|
|
|
|
"value": string
|
|
|
|
],
|
|
|
|
"schedule": [
|
|
|
|
{
|
|
|
|
"occurrence" string,
|
|
|
|
"minute": [
|
|
|
|
string
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
string
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
string
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
string
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
string
|
|
|
|
],
|
|
|
|
"occurrence": string,
|
|
|
|
"user": string,
|
|
|
|
"command": string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2020-02-04 14:19:33 -08:00
|
|
|
## parse
|
|
|
|
```python
|
|
|
|
parse(data, raw=False, quiet=False)
|
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) output preprocessed JSON if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
Dictionary. Raw or processed structured data.
|
|
|
|
|