skip @reboot line for cron
This commit is contained in:
@@ -62,13 +62,18 @@ def discover_cron_expr(command_hint: str, *, archive: bool) -> Optional[str]:
|
|||||||
|
|
||||||
``command_hint`` is a substring identifying the scrape command (e.g.
|
``command_hint`` is a substring identifying the scrape command (e.g.
|
||||||
"scraper.py"); ``archive`` picks the "--archive" line vs. the plain one.
|
"scraper.py"); ``archive`` picks the "--archive" line vs. the plain one.
|
||||||
Returns None if the crontab can't be read or no line matches.
|
Each scrape typically has two crontab lines - an "@reboot" one and a
|
||||||
|
timed one; "@reboot" isn't a recurring schedule (croniter can't compute
|
||||||
|
a next run from it), so it's skipped in favor of the timed line.
|
||||||
|
Returns None if the crontab can't be read or no timed line matches.
|
||||||
"""
|
"""
|
||||||
for line in _read_crontab_lines():
|
for line in _read_crontab_lines():
|
||||||
parsed = _parse_crontab_line(line)
|
parsed = _parse_crontab_line(line)
|
||||||
if parsed is None:
|
if parsed is None:
|
||||||
continue
|
continue
|
||||||
schedule, command = parsed
|
schedule, command = parsed
|
||||||
|
if schedule.lower() == "@reboot":
|
||||||
|
continue
|
||||||
if command_hint not in command:
|
if command_hint not in command:
|
||||||
continue
|
continue
|
||||||
if ("--archive" in command) != archive:
|
if ("--archive" in command) != archive:
|
||||||
|
|||||||
Reference in New Issue
Block a user