am writing my very first shell script and need some assistance. What I need help on is three things in particular.
1) Do I need to use the sleep function after the tar command or does the script know to wait until tar finishes to move on to the next line?
2) Did I populate the variable DATE correctly? I want it to be populated in the format MMDDYY.
3) How do I calculate the date from two days ago so that I only keep two backups on the server?
Here is what I have so far
#ServiceCenter Backup Script
#Author: Robert McDougal
#Date: 11/18/2009
#Last Updated: 11/18/2009
RUN_DIR=/Web/servers/servicecenter/RUN
BACKUP_DIR=/Web/servers/servicecenter/...
SC_DIR=/Web/servers/servicecenter
DATE=date '%m%d%y'
#Changing to the RUN directory
cd RUN_DIR
#Scheduling a regular shutdown of ServiceCenter(Can take up to 10 min).
scstop u -s
#The script will wait 10 minutes before proceeding to the next command
#This is to ensure that servicecenter shuts down completely before proceeding.
sleep 600
#This code will cause service center to force close immediately.
scstop u -if
#Changing to the Servicecenter Directory
cd SC_DIR
#Tar'ing the data directory
tar ./Backups/DATE.tar data
#Changing back to the run directory
cd RUN_DIR
#Starting ServiceCenter back up
scstart
#Changing to the Backup directory
cd BACKUP_DIR
#Gzipping the lattest backup
gzip DATE.tar
#Deleting the backup from two days ago
rm DATE-2.*
exit