I have a RHEL server that I am running a MySQL database on. I have a BASH script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in BASH is 754259 in size. If I execute the same script with Cron, it's only 20 in size.
As far as I know, Cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.
Why are the file sizes different when running the same script?
The shell script contents:
sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz