Skip to content
Advertisement

linux bash script log output

Im having trouble getting output into my log file in my script. Backup runs successfully but the logfile is empty. WHen I run the script I get “Warning: Using a password on the command line interface can be insecure.” so at least that should be in a log file. (I am using a .key file)

mysqldump  -u root -p$Pass   --all-databases | gzip > fulldbdmp-$(date +%m%d%Y).dump.gz 2> file.log

Advertisement

Answer

Thats because, only error from your gzip execution goes into file. To get what you want, use –

mysqldump -u root -p$Pass --all-databases 2>file.log | gzip > fulldbdmp-$(date +%m%d%Y).dump.gz

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement