- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to get 5th Saturday?
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
Discussions
Discussions
Forums
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
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
тАО05-10-2007 05:20 AM
тАО05-10-2007 05:20 AM
We are allowed scheduled maintenance times 4 times each year on the 5th Saturday of a month. Is there a way to find the 5th Saturdays throughout the year so that we can automatically notify our users?
Thanks,
Ryan
Solved! Go to Solution.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 05:39 AM
тАО05-10-2007 05:39 AM
Re: How to get 5th Saturday?
year=2007
for i in 01 02 03 04 05 06 07 08 09 10 11 12
do
cal ${i} ${year} | grep -v [A-Z,a-z] grep [0-9]
done
will give you the monthly calendars.
store them in separate files and look for ones with 5 or 6 lines. In these files, 5th saturday is the last (7th field of) line number 5.
Sorry I can not write the code for you as I have some buisness to tend right now, but this should get you going I hope.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 05:39 AM
тАО05-10-2007 05:39 AM
Re: How to get 5th Saturday?
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 05:43 AM
тАО05-10-2007 05:43 AM
Re: How to get 5th Saturday?
http://www.hpux.ws/caljd.sh
http://www.hpux.ws/caljd.pl
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- caljd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 06:30 AM
тАО05-10-2007 06:30 AM
Re: How to get 5th Saturday?
Set environmental variable Y to the year of interest (e.g. Y=$(date +%Y)), and then:
for M in 01 02 03 04 05 06 07 08 09 10 11 12
do
cal ${M} ${Y} | awk -v M=${M}-v Y=${Y} 'NR==7 {if($7 !~ /^$/){printf("%s/%s/%s\n",M,$7,Y)}}'
done
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 07:15 AM
тАО05-10-2007 07:15 AM
SolutionThis should work.
dayofmonth.pl -w 6 -n 5
without a year argument the current year is assummed.
dayofmonth.pl -w 6 -n 5 2012
will work for 2012.
Invoke as dayofmonth.pl -u for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 07:16 AM
тАО05-10-2007 07:16 AM
Re: How to get 5th Saturday?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2007 09:39 AM
тАО05-10-2007 09:39 AM
Re: How to get 5th Saturday?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 12:48 AM
тАО05-11-2007 12:48 AM
Re: How to get 5th Saturday?
18 * * * 6 [`date "+%d"` -gt 28] && /path/to/script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 01:59 AM
тАО05-11-2007 01:59 AM
Re: How to get 5th Saturday?
--- special-saturdays.pl ---
use strict;
my $try = time();
my $DAY = 86400; # 24 * 60 *60
for (0..365) {
$try += $DAY;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($try);
print scalar localtime($try)."\n" if ($wday == 6 and $mday > 28);
}
#perl special-saturdays.pl
Sat Jun 30 06:53:49 2007
Sat Sep 29 06:53:49 2007
Sat Dec 29 05:53:49 2007
Sat Mar 29 05:53:49 2008
Similar building your own date format...
use strict;
my $try = time();
my $DAY = 86400; # 24 * 60 *60
for (0..365) {
$try += $DAY;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($try);
printf "%d-%02d-%02d\n",$year+1900,$mon+1,$mday if ($wday == 6 and $mday > 28);
}
perl special-saturdays.pl
2007-06-30
2007-09-29
2007-12-29
2008-03-29
fwiw,
Hein.
- Tags:
- Perl