OT ? Shell script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Les Mikesell wrote:

>On Sun, 2005-12-04 at 15:35, Jonathan Wright wrote:
>  
>
>>Robert wrote:
>>    
>>
>>>Considering my nebulous request and your apparent lack of expertise in 
>>>applied clairvoyance, fine.
>>>The "3rd Monday" part is used in generating reminders to a each of a 
>>>group of OldFarts that gets together monthly to inventory aches, pains 
>>>and, yes, empty chairs. The "Sunday before" requirement will be used to 
>>>run a script (already working) to create a series of image files 
>>>containing critical stuff, to be burned (manually) to DVDs to go with me 
>>>to the meeting, to be given to a trusted person for safekeeping.
>>>
>>>The following is what I have now, stripped down to the bare essentials 
>>>for clarity(?):
>>>      
>>>
>>Looking at the way you've done it, you could to it like this:
>>
>>if [$(date +%d) == $(date +%d -d $(date +%Y\/%m)/$((21-$(($(date +%w -d $(date +%Y\/%m)/21)-1)))))];
>>then
>>   // do 3rd Monday stuff...
>>elif [$(date +%d) == $(date +%d -d $(date +%Y\/%m)/$((21-$(($(date +%w -d $(date +%Y\/%m)/21))))))];
>>then
>>   // do Sunday before stuff
>>else
>>   // do nothing :)
>>fi
>>
>>and therefore run the NSS.sh script directly.
>>    
>>
>
>My math is too fuzzy to decipher that.  How about running this
>every Sunday from cron?
>
>DOM=`date --date=tomorrow +%d`
>if [ "$DOM" -lt 15 -o "$DOM" -gt 21 ]
> then exit
>fi
>..rest of script goes here...
>
>I think that means today's %d must be between 14 and 20,
>but the concept is handy because the string you hand
>date= can be something like 'today + 2 weeks' if you
>need to track things that fall into next month.
>
>  
>
Thanks to all for the responses.  One of the really neat things about 
*nix is the fact that there are so many solutions to any given problem.  
One of the really neat things about CentOS is this list.

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux