- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: getting specific cron dates
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 10:42 PM
06-11-2006 10:42 PM
our cronlog cron has over 700 jobs in the schedule, I want to find every job that starts after 20:00 on the server on a saturday.
possible strings= "*", "1-6" "5"
I have some idea how to do this but could someone suggest a solution please?
Thanks
Solved! Go to Solution.
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 11:43 PM
06-11-2006 11:43 PM
SolutionTry this:
# cat ./sats
#!/usr/bin/perl -an
next if /\s*#/;
next unless $F[1]=~/20/ or $F[1] > 20 or $F[1] eq "\*";
next unless $F[4]=~/6/ or $F[4] eq "\*";
print;
1;
Run as:
# crontab -l | ./sats
This finds crontasks that are not commented-out; and are run on Saturday (day=6) or everyday of the week every hour, after 2000 hours or in a range including 2000 hours.
Note that Perl counts zero-relative. Hence, $F[1] is the *second* crontab field.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 12:22 AM
06-12-2006 12:22 AM
Re: getting specific cron dates
Thanks for the help, I am not familiar with perl so unable to troubleshoot - here is the output:
--> crontab -l |./sats
+ ./sats
+ crontab -l
./sats[3]: next: not found.
./sats[4]: next: not found.
./sats[5]: next: not found.
./sats[7]: 1: 0403-006 Execute permission denied.
permissions are 777 on the file - owned and run by root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 12:23 AM
06-12-2006 12:23 AM
Re: getting specific cron dates
Are you only interested in jobs running from 20:00 until 23:59 Saturday night, or are you also interested in some jobs which run early Sunday morning?
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 12:25 AM
06-12-2006 12:25 AM
Re: getting specific cron dates
# crontab -l
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 12:29 AM
06-12-2006 12:29 AM
Re: getting specific cron dates
Are you sure that your included the "shebang" (#!) line that declares the Perl interpreter?
You may need to change the location for Perl to match your server. Do:
# whereis perl
# which perl
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 01:37 AM
06-12-2006 01:37 AM
Re: getting specific cron dates
/usr/bin/perl
and is the same in the script
any idea James?
Ty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 01:43 AM
06-12-2006 01:43 AM
Re: getting specific cron dates
Well, if you cut-and-pasted the script I posted, there should only be six lines whereas the errors suggest that you have seven.
What do these show?
# ls -l /usr/bin/perl
# /usr/bin/perl -v
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2006 01:59 AM
06-12-2006 01:59 AM
Re: getting specific cron dates
James, muchas gracias - my issue was I copied your solution and pasted to my script however in my haste I managed to add # cat sats.
This works - brilliant!
Mr Law