Operating System - HP-UX
1833758 Members
2561 Online
110063 Solutions
New Discussion

Crontab and print only Monday jobs

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Crontab and print only Monday jobs

Hi,

How can I print to the screen only the jobs that run on Mondays?
8 REPLIES 8
Marco A.
Esteemed Contributor

Re: Crontab and print only Monday jobs

What's your job structure?!... can we see it?!
Just unplug and plug in again ....
Wouter Jagers
Honored Contributor

Re: Crontab and print only Monday jobs

Eek, tough question..

I suppose you could start by checking for "1" and "*" in the 5th field of the crontab like this:

# crontab -l | awk '{if($5~/1/||$5~/\*/){ print}}'

BUT of course we'll be missing things:
- A day field of "0-6" (sunday to saturday) will not be caught.. but I bet with some fiddling that could be fixed.
- A job scheduled to run yearly on May 15th would run next monday. Catching these will be something else.

How detailed do you need to know ? :-)
an engineer's aim in a discussion is not to persuade, but to clarify.
Jeff_Traigle
Honored Contributor

Re: Crontab and print only Monday jobs


crontab -l | grep -v "^#" | awk '{if ($5 == 1) print}'
--
Jeff Traigle
Jeff_Traigle
Honored Contributor

Re: Crontab and print only Monday jobs

Oops. I'm not thinking in complicated terms this morning. The previous answer covers the bases much better.
--
Jeff Traigle
Oviwan
Honored Contributor
Solution

Re: Crontab and print only Monday jobs

Hey

0 for monday

#crontab -l | awk '{ if($5 ~ /[0]/) { print $0 }}'

Regards
Coolmar
Esteemed Contributor

Re: Crontab and print only Monday jobs

thanks
Wouter Jagers
Honored Contributor

Re: Crontab and print only Monday jobs

man crontab:
weekday - The day of the week, 0-6, 0=Sunday

Make sure to look for the right day ;-)

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
Oviwan
Honored Contributor

Re: Crontab and print only Monday jobs

ups my mistake, tested with sunday :)