Quote:
Originally Posted by
cfajohnson
In what way does it not execute? What happens? Do you get any error messages? Any output?
Please enclode code in [code] tags.
Where have you initialized $DirCount?
Have you looked at the output of ls -t /data/backups | tails --line=1? That's what you are passing to rm.
The line in question does not throw any errors, the end result that I am looking for (and see when it is run from the command line) simply doesn not happen (i.e. the oldest directory being removed)
All variables were initialized at the top of the script and opearted as advertised. Initialization is as follows prior to loop :
[
NUMBER_OF_BACKUPS=2
BACKUP_DIR=/data/backups
DATE_FORMAT="+%Y-%m-%d_%H_%M_%S"
SRM_DIR=sub
DirCount=`ls /data/backups -1A | wc -l`
if [ $DirCount -ge $NUMBER_OF_BACKUPS ]
then
echo "Reached Maximum of $NUMBER_OF_BACKUPS Backups : Performing Cleanup"
fi
]
Yes, I have looked at the output of the
ls -t /data/backups | tails --line=1 command. It contained the name of the oldest directory as expected. Using bash -x to run the script I see rm -rf <name>, agian as I would expect however the directory fails to be removed. Permissions all seem to be set open to allow this to occur.