Reputation: 119
I have this regex:
^\h*(?:(?:\*|[0-9]+)\/0*(?:[0-4]))(?:\s+\*){4}
And I have these strings of cron jobs:
2,5,8,27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
5,5,8,27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
200,5,8,27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
*/16 * * * * /bin/echo 0
*/13 * * * * /bin/echo 0
*/4 * * * * /bin/echo 0
*/2 * * * * /bin/echo 0
*/3 * * * * /bin/echo 0
110,5,8,27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
The result of the regex above is:
*/4 * * * * /bin/echo 0
*/2 * * * * /bin/echo 0
*/3 * * * * /bin/echo 0
But it does not detect other cron jobs that run below 4 minutes like this:
2,5,8,27,30,36,12,15,18,21,24,39,42 * * * * /bin/echo 0
So that one runs every 2 minutes, 5 minutes, 27, etc.
I would like to detect all lines of cron jobs that run below 5 minutes.
You can see my regex example here: https://regex101.com/r/iJmdvl/1
Thanks in advance.
Upvotes: 0
Views: 531
Reputation: 3549
Here give this a try -
^(\*?\/?[0-4])(?:\s|,)
Which can be tested here -
https://regex101.com/r/U1MzYt/1/
This will just match the first part of each line if it contains */ conditionally and if it's followed (or starts with) [0-4].
Upvotes: 1