Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Running Script via Crontab on 2nd Working day each month Post 302571871 by vbe on Tuesday 8th of November 2011 11:51:58 AM
Old 11-08-2011
Wait a minute...
your exemple makes monday the 1rst working day not the second...

Can you be a bit more clear

Last edited by vbe; 11-08-2011 at 12:55 PM.. Reason: Did not understand the request... (time to leave?)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies

2. Shell Programming and Scripting

Get Last working day of the month

Hi I need a script to get "Last working day of the month". I will pass the month and year as parameters and i need to get the last working date. Ex for June 2008 the last working day is 30th its monday. for August 2008 the last working day is 29th and it is Friday. ie the last working... (6 Replies)
Discussion started by: manmarirama
6 Replies

3. Shell Programming and Scripting

last working day of previous month

Hi, I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Discussion started by: rspk_praveen
1 Replies

4. UNIX for Dummies Questions & Answers

cron script -run every 2nd day of month except Monday

I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this? How do I exclude Monday if the 2nd day of the month falls on a Monday? Thanks. I tried this: 0 0 2 * 0,2-6 command And I know this doesnt... (2 Replies)
Discussion started by: newtou
2 Replies

5. Shell Programming and Scripting

crontab entry to run every last day of the month

i've created a script which should run every last day of the month. what would be the exact crontab entry for this? thanks! (9 Replies)
Discussion started by: tads98
9 Replies

6. Shell Programming and Scripting

How to find the first working day of month ?

Hi, How to find the first working day of month ? My requirement is, I need to call the function only if today is first working day of month. I could find out one function which finds last working day in month in this forum. Can anyone pls let me know for first working day. Thanks. for... (10 Replies)
Discussion started by: vnimavat
10 Replies

7. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

8. Shell Programming and Scripting

Need help in running script on last day of month

Hello Experts/Guru, I need a help in running the script on every month last day.... PS: due to some constrain I can't schedule in crontab Requirement: On Jan 31st i want to run some script, similarly on Feb 28th, March 31st, April 30th......till Dec 31st. Please help me by providing... (3 Replies)
Discussion started by: aks_1902
3 Replies

9. Shell Programming and Scripting

Find Month first Working Day

Hi, I would like to calculate 1st working/Business day of each month. Exp: 1st -Oct-2011 is Saturday--- Non Business Day So the Next Working Day would be 3-Oct-2011 I need a shell script to calculate the month first business date. (3 Replies)
Discussion started by: koti_rama
3 Replies

10. Shell Programming and Scripting

Simpler crontab entry to execute pgm on last day of the month

The following bash command line works for the last day of the month. Test by replacing the 1 with tomorrows day of month number && echo "Day before tomorrow"Can it be used within crontab? As * * 28-31 * * && echo "Today ls last day of month" >>/tmp/crontabtestI tried to test crontab with... (1 Reply)
Discussion started by: lsatenstein
1 Replies
DateTime::Format::Builder::Tutorial(3pm)		User Contributed Perl Documentation		  DateTime::Format::Builder::Tutorial(3pm)

NAME
DateTime::Format::Builder::Tutorial - Quick class on using Builder CREATING A CLASS
As most people who are writing modules know, you start a package with a package declaration and some indication of module version: package DateTime::Format::ICal; our $VERSION = '0.04'; After that, you call Builder with some options. There are only a few (detailed later). Right now, we're only interested in parsers. use DateTime::Format::Builder ( parsers => { ... } ); The parsers option takes a reference to a hash of method names and specifications: parsers => { parse_datetime => ... , parse_datetime_with_timezone => ... , ... } Builder will create methods in your class, each method being a parser that follows the given specifications. It is strongly recommended that one method is called parse_datetime, be it a Builder created method or one of your own. In addition to creating any of the parser methods it also creates a "new()" method that can instantiate (or clone) objects of this class. This behaviour can be modified with the constructor option, but we don't need to know that yet. Each value corresponding to a method name in the parsers list is either a single specification, or a list of specifications. We'll start with the simple case. parse_briefdate => { params => [ qw( year month day ) ], regex => qr/^(dddd)(dd)(dd)$/, }, This will result in a method named parse_briefdate which will take strings in the form 20040716 and return DateTime objects representing that date. A user of the class might write: use DateTime::Format::ICal; my $date = "19790716"; my $dt = DateTime::Format::ICal->parse_briefdate( $date ); print "My birth month is ", $dt->month_name, " "; The "regex" is applied to the input string, and if it matches, then $1, $2, ... are mapped to the params given and handed to "DateTime->new()". Essentially: my $rv = DateTime->new( year => $1, month => $2, day => $3 ); There are more complicated things one can do within a single specification, but we'll cover those later. Often, you'll want a method to be able to take one string, and run it against multiple parser specifications. It would be very irritating if the user had to work out what format the datetime string was in and then which method was most appropriate. So, Builder lets you specify multiple specifications: parse_datetime => [ { params => [ qw( year month day hour minute second ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)(dd)$/, }, { params => [ qw( year month day hour minute ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)$/, }, { params => [ qw( year month day hour ) ], regex => qr/^(dddd)(dd)(dd)T(dd)$/, }, { params => [ qw( year month day ) ], regex => qr/^(dddd)(dd)(dd)$/, }, ], It's an arrayref of specifications. A parser will be created that will try each of these specifications sequentially, in the order you specified. There's a flaw with this though. In this example, we're building a parser for ICal datetimes. One can place a timezone id at the start of an ICal datetime. You might extract such an id with the following code: if ( $date =~ s/^TZID=([^:]+):// ) { $time_zone = $1; } # Z at end means UTC elsif ( $date =~ s/Z$// ) { $time_zone = 'UTC'; } else { $time_zone = 'floating'; } $date would end up without the id, and $time_zone would contain something appropriate to give to DateTime's set_time_zone method, or time_zone argument. But how to get this scrap of code into your parser? You might be tempted to call the parser something else and build a small wrapper. There's no need though because an option is provided for preprocesing dates: parse_datetime => [ [ preprocess => &_parse_tz ], # Only changed line! { params => [ qw( year month day hour minute second ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)(dd)$/, }, { params => [ qw( year month day hour minute ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)$/, }, { params => [ qw( year month day hour ) ], regex => qr/^(dddd)(dd)(dd)T(dd)$/, }, { params => [ qw( year month day ) ], regex => qr/^(dddd)(dd)(dd)$/, }, ], It will necessitate _parse_tz to be written, and that routine looks like this: sub _parse_tz { my %args = @_; my ($date, $p) = @args{qw( input parsed )}; if ( $date =~ s/^TZID=([^:]+):// ) { $p->{time_zone} = $1; } # Z at end means UTC elsif ( $date =~ s/Z$// ) { $p->{time_zone} = 'UTC'; } else { $p->{time_zone} = 'floating'; } return $date; } On input it is given a hash containing two items: the input date and a hashref that will be used in the parsing. The return value from the routine is what the parser specifications will run against, and anything in the parsed hash ($p in the example) will be put in the call to "DateTime->new(...)". So, we now have a happily working ICal parser. It parses the assorted formats, and can also handle timezones. Is there anything else it needs to do? No. But we can make it work more efficiently. At present, the specifications are tested sequentially. However, each one applies to strings of particular lengths. Thus we could be efficient and have the parser only test the given strings against a parser that handles that string length. Again, Builder makes it easy: parse_datetime => [ [ preprocess => &_parse_tz ], { length => 15, # We handle strings of exactly 15 chars params => [ qw( year month day hour minute second ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)(dd)$/, }, { length => 13, # exactly 13 chars... params => [ qw( year month day hour minute ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)$/, }, { length => 11, # 11.. params => [ qw( year month day hour ) ], regex => qr/^(dddd)(dd)(dd)T(dd)$/, }, { length => 8, # yes. params => [ qw( year month day ) ], regex => qr/^(dddd)(dd)(dd)$/, }, ], Now the created parser will create a parser that only runs specifications against appropriate strings. So our complete code looks like: package DateTime::Format::ICal; use strict; our $VERSION = '0.04'; use DateTime::Format::Builder ( parsers => { parse_datetime => [ [ preprocess => &_parse_tz ], { length => 15, params => [ qw( year month day hour minute second ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)(dd)$/, }, { length => 13, params => [ qw( year month day hour minute ) ], regex => qr/^(dddd)(dd)(dd)T(dd)(dd)$/, }, { length => 11, params => [ qw( year month day hour ) ], regex => qr/^(dddd)(dd)(dd)T(dd)$/, }, { length => 8, params => [ qw( year month day ) ], regex => qr/^(dddd)(dd)(dd)$/, }, ], }, ); sub _parse_tz { my %args = @_; my ($date, $p) = @args{qw( input parsed )}; if ( $date =~ s/^TZID=([^:]+):// ) { $p->{time_zone} = $1; } # Z at end means UTC elsif ( $date =~ s/Z$// ) { $p->{time_zone} = 'UTC'; } else { $p->{time_zone} = 'floating'; } return $date; } 1; And that's an ICal parser. The actual DateTime::Format::ICal module also includes formatting methods and parsing for durations, but Builder doesn't support those yet. A drop in replacement (at the time of writing the replacement) can be found in the examples directory of the Builder distribution, along with similar variants of other common modules. SUPPORT
Any errors you see in this document, please log them with CPAN RT system via the web or email: http://perl.dellah.org/rt/dtbuilder bug-datetime-format-builder@rt.cpan.org This makes it much easier for me to track things and thus means your problem is less likely to be neglected. LICENSE AND COPYRIGHT
Copyright X Iain Truskett, 2003. All rights reserved. You can redistribute this document and/or modify it under the same terms as Perl itself. The full text of the licenses can be found in the Artistic and COPYING files included with this document. AUTHOR
Iain Truskett <spoon@cpan.org> SEE ALSO
"datetime@perl.org" mailing list. http://datetime.perl.org/ perl, DateTime, DateTime::Format::Builder perl v5.10.1 2010-03-14 DateTime::Format::Builder::Tutorial(3pm)
All times are GMT -4. The time now is 06:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy