Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: cron: every nth week

by runrig (Abbot)
on Jan 01, 2002 at 02:57 UTC ( [id://135452]=note: print w/replies, xml ) Need Help??


in reply to cron: every nth week

If you're scheduling the script to run every Monday (and only on Monday, or whatever day you're after), then can just see if its the nth week of the month. Here's a version that doesn't use modules (notice there's no real difference between bad input and a day that's not the nth week):
my $nth = shift; die "N must be numeric" if $nth =~ /\D/; die "Day is out of range" if $nth > 5; my ($mday) = (localtime)[3]; my $weeks = int(($mday-1)/7)+1; exit 0 if $weeks == $nth; exit 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://135452]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found