2021-04-09 10:36:42 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2019-12-16 17:52:09 -08:00
|
|
|
# jc.parsers.crontab
|
2020-08-05 16:51:58 -07:00
|
|
|
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
|
|
|
|
|
|
|
Supports `crontab -l` command output and crontab files.
|
2019-12-16 17:52:09 -08:00
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (cli):
|
2019-12-16 17:52:09 -08:00
|
|
|
|
2020-08-05 16:51:58 -07:00
|
|
|
$ crontab -l | jc --crontab
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
$ jc crontab -l
|
2019-12-16 17:52:09 -08:00
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc.parsers.crontab
|
|
|
|
result = jc.parsers.crontab.parse(crontab_output)
|
|
|
|
|
2021-04-08 11:24:02 -07:00
|
|
|
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,
|
|
|
|
"command": string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-12-16 17:52:09 -08:00
|
|
|
Examples:
|
|
|
|
|
2020-02-13 16:58:25 -08:00
|
|
|
$ crontab -l | jc --crontab -p
|
2019-12-16 17:52:09 -08:00
|
|
|
{
|
|
|
|
"variables": [
|
|
|
|
{
|
|
|
|
"name": "MAILTO",
|
|
|
|
"value": "root"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "PATH",
|
|
|
|
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "SHELL",
|
|
|
|
"value": "/bin/bash"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"schedule": [
|
|
|
|
{
|
|
|
|
"minute": [
|
|
|
|
"5"
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
"10-11",
|
|
|
|
"22"
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": [
|
|
|
|
"30"
|
|
|
|
],
|
|
|
|
"hour": [
|
|
|
|
"4/2"
|
|
|
|
],
|
|
|
|
"day_of_month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"month": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"day_of_week": [
|
|
|
|
"*"
|
|
|
|
],
|
|
|
|
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "yearly",
|
|
|
|
"command": "/home/maverick/bin/annual-maintenance"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "reboot",
|
|
|
|
"command": "/home/cleanup"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "monthly",
|
|
|
|
"command": "/home/maverick/bin/tape-backup"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-12-16 18:54:19 -08:00
|
|
|
$ cat /etc/crontab | jc --crontab -p -r
|
2019-12-16 17:52:09 -08:00
|
|
|
{
|
|
|
|
"variables": [
|
|
|
|
{
|
|
|
|
"name": "MAILTO",
|
|
|
|
"value": "root"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "PATH",
|
|
|
|
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "SHELL",
|
|
|
|
"value": "/bin/bash"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"schedule": [
|
|
|
|
{
|
|
|
|
"minute": "5",
|
|
|
|
"hour": "10-11,22",
|
|
|
|
"day_of_month": "*",
|
|
|
|
"month": "*",
|
|
|
|
"day_of_week": "*",
|
|
|
|
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"minute": "30",
|
|
|
|
"hour": "4/2",
|
|
|
|
"day_of_month": "*",
|
|
|
|
"month": "*",
|
|
|
|
"day_of_week": "*",
|
|
|
|
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "yearly",
|
|
|
|
"command": "/home/maverick/bin/annual-maintenance"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "reboot",
|
|
|
|
"command": "/home/cleanup"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"occurrence": "monthly",
|
|
|
|
"command": "/home/maverick/bin/tape-backup"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2019-12-16 17:52:09 -08:00
|
|
|
## info
|
|
|
|
```python
|
2020-07-30 16:20:24 -07:00
|
|
|
info()
|
2019-12-16 17:52:09 -08:00
|
|
|
```
|
2021-04-08 11:24:02 -07:00
|
|
|
Provides parser metadata (version, author, etc.)
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2019-12-16 17:52:09 -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:
|
|
|
|
|
2019-12-17 10:09:19 -08:00
|
|
|
Dictionary. Raw or processed structured data.
|
2019-12-16 17:52:09 -08:00
|
|
|
|
2021-04-09 10:36:42 -07:00
|
|
|
## Parser Information
|
|
|
|
Compatibility: linux, darwin, aix, freebsd
|
|
|
|
|
2021-12-01 16:12:51 -08:00
|
|
|
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|