![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help in automating dates in ksh script | italia1971luca | Shell Programming and Scripting | 1 | 06-04-2008 03:29 AM |
| Event Cloud Computing - IBM Turning Data Centers Into ?Computing Cloud? | iBot | Complex Event Processing RSS News | 0 | 11-15-2007 05:30 PM |
| How to compare the dates in shell script | vaji | Shell Programming and Scripting | 9 | 02-27-2007 09:34 PM |
| Trusted Computing | kduffin | Security | 0 | 06-15-2006 12:07 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
computing go/no-go dates in script
I am working on a bash script to backup selected servers and am trying to come up with a simpler solution to this problem:
Each server to be backed up has a config file that is read by the script, in the config file are the following values: LEVEL0=12 #this is the day of the month on which level zero backups are performed. INTERVAL=3: #In this case every 3 days before or after the LEVEL0 date an interval backup will be performed. The LEVEL0 and INTERVAL values will be different for different servers. I could just write a loop to compute if the current day is a day on which to perform an interval backup but it seems that there must be a simpler way to calculate this. If anyone can point me in the right direction I would appreciate it very much. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
If I am not wrong, you just have to determine if the date is one on which an interval backup is to be taken. You could use something like this:
Code:
#!/usr/bin/ksh d=$(date +%d) if [ $(($LEVEL0 - $INTERVAL)) -eq $d -o $(($LEVEL0 + $INTERVAL)) -eq $d ]; then #### take backup here fi |
|
#3
|
|||
|
|||
|
If you need an interval backup on every INTERVAL days before and after the full backup date then how about using a modulus from the full day number:
Code:
LEVEL0=12 ;# read these value from ...
INTERVAL=3 ;# ... parameter file
d=$(date +%d)
if [ $LEVEL0 -eq $d ]; then
print backup is Full on day $d ;# replace by doing something useful here ...
else
if [ $(( ($d - $LEVEL0) % $INTERVAL)) -eq 0 ]; then
print backup is Interval on day $d ;# ... and here
fi
fi
|
|
#4
|
|||
|
|||
|
Quote:
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|