crontab entries starting with double octothorpe ('##') are omitted
similar to issues 74 and 63, disabled crontab entries that start with '##' confuse the parser. Seems to be consistent with both "live" crontab (user='x') and crontab read from a file (tabfile='x.x'). It appears the lines are erroneously considered comments, instead of as a CronItem.
for example, in these 3 crontab entries, only the first and third are reported as crontab entries:
# 02 14 * * * /apps/bob/cron/trigger_eod.sh # one comment
## 02 14 * * * /apps/bob/cron/two_hashes.sh # two comments; not seen by CronTab
# 02 14 * * * /apps/bob/cron/trigger_eod.sh # comment with leading space
to validate the issue:
- create a file named crontab.bug containing the above 3 lines
- run the python below
- observe the issue
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from crontab import CronTab
>>> c = CronTab(tabfile='crontab.bug')
>>> for j in c:
... print(j)
...
# 2 14 * * * /apps/bob/cron/trigger_eod.sh # one comment
# 2 14 * * * /apps/bob/cron/trigger_eod.sh # comment with leading space
>>>
>>> for line in c.lines:
... print(line)
...
# 2 14 * * * /apps/bob/cron/trigger_eod.sh # one comment
## 02 14 * * * /apps/bob/cron/two_hashes.sh # two comments; not seen by CronTab
# 2 14 * * * /apps/bob/cron/trigger_eod.sh # comment with leading space
>>>
>>> print(c.lines)
[<CronItem '# 2 14 * * * /apps/bob/cron/trigger_eod.sh # one comment'>, '## 02 14 * * * /apps/bob/cron/two_hashes.sh # two comments; not seen by CronTab\r', <CronItem '# 2 14 * * * /apps/bob/cron/trigger_eod.sh # comment with leading space'>]
>>>
Edited by Martin Owens