I created a script that will check for the existence of .gz files in the base directory and if it finds them it moved them into a new structure based on the current date. The script works perfectly when the shell is set to /bin/bash and I run it manually, but this script is run as a cron job (by logrotate) and I believe that it MUST be run under /bin/sh as I am not sure how to get logrotate to run it under /bin/bash. The code in question is
# Move rotated logs to the archive
if [ -f $BASEDIR/*.gz ]; then
logger "$SNAME Moving rotated logs to $DIRECTORY"
mv $BASEDIR/*.gz $DIRECTORY
else
echo "$BASEDIR/*.gz"
logger "$SNAME No rotated logs to move. Is this normal?"
fi
In bash the conditional check works great, under sh it complains there are too many arguments. If I put things in quotes it doesn't see the wildcard and aways returns false.
Any help would be fantastic!