Current script:
#!/bin/sh
declare -i r_code=0 # initialize the script's return code
cd /opt/software/dbascripts
# the dbbkp.auth file has the name of the db user and db password
source ../dbaauthfiles/dbbkp.auth
NEW=`date +"%Y%m" --date="next month"`
OLD=`date +"%Y%m" --date="last month"`
PARTITION=`date --date="+2 month -$(($(date +"%d")-1)) days 00:00:00" +"%s"`
echo "$PARTITION"
echo "Creating p$NEW and deleting p$OLD"
mysql --batch -u$DB_USER -p$DB_PASSWORD db -f << eof
ALTER TABLE table1 ADD PARTITION ( PARTITION p$NEW VALUES LESS THAN ($PARTITION));
ALTER TABLE table1 DROP PARTITION p$OLD ;
eof
r_code+=$?
echo "### Completed ${0##*/}, exiting with return code $r_code"
exit $r_code
This fails to work on certain days of the month, but I need it to be able to run no matter what day of the month it runs.
Error when I ran this on the 8th of the month:
line 11: 08: value too great for base (error token is "08")
Warning: Using a password on the command line interfac
I know this has something to do with how octal numbers are looked at from bash/Linux perspective, but I'm not sure how to correct this.
e can be insecure.