1833571 Members
3142 Online
110061 Solutions
New Discussion

Re: crontab entries

 
SOLVED
Go to solution
Dave Walley
Frequent Advisor

crontab entries

Hi.

I need to find all lines in crontab files that have numeric values in the first 4 fields (at least). For example I would want the first and third lines returned in this example

00 07 24 7 * /home/ggewrgwer
00 07 * * 2-6 /home/cleanup
00 07 24 7 1-5 /home/ggewrgwer

Any help would be greatly appreciated.

Dave
why do i do this to myself
7 REPLIES 7
Krishna Prasad
Trusted Contributor

Re: crontab entries

crontab -l | awk ' $1~/^0-9/ && $2~/^0-9/ && $3~/^0-9/ && $4~/^[0-9/ '
Positive Results requires Positive Thinking
Krishna Prasad
Trusted Contributor

Re: crontab entries

whoops

try this

crontab -l | awk ' $1~/^[0-9]/ && $2~/^[0-9]/ && $3~/^[0-9]/ && $4~/^[0-9]/ '
Positive Results requires Positive Thinking
Volker Borowski
Honored Contributor

Re: crontab entries

I guess it should read like

awk '{ print ..... }'

Volker
Mark Greene_1
Honored Contributor

Re: crontab entries

try a little reverse logic:

crontab -l |grep -v "#"|grep -v "*"|pg

HTH
mark
the future will be a lot like now, only later
harry d brown jr
Honored Contributor

Re: crontab entries

Maybe something like this:

crontab -l | grep "^[0-6]*[0-9] [0-2]*[0-9] [0-3][0-9] [0-9]*[0-9]"


live free or die
harry
Live Free or Die
Krishna Prasad
Trusted Contributor

Re: crontab entries

FYI-

Don't need the 'print' when you want the entire line to be displayed.
Positive Results requires Positive Thinking
Wodisch
Honored Contributor
Solution

Re: crontab entries

crontab -l |
grep "^[0-9][0-9]* [0-9][0-9]* [0-9][0-9]* [0-9][0-9]* "

or even shorter:

crontab -l |
egep "^[0-9]+ [0-9]+ [0-9]+ [-0]+ "

HTH,
Wodisch