Copy tmux Scroll Buffer to a File

tmux is super handy for long running commands. Especially if you have a dodgy connection which is likely to break: the command will keep running and you can re-attach to the session to save the day. But as a dyed-in-the-wool bash user, I've kinda got used to being able to scroll up and down my … Read more

Advanced Bash logging to handle errors.

So we've all done a quick log from a bash script, which looks like this

LOGFILE="logs/$(date +%F)_backup.log"
# Append to the file
restic backup /etc/ >> $LOGFILE
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print >> $LOGFILE

That's great for small scripts. But sometimes you find that its not logging errors, which are also helpful, and you need to add those:

LOGFILE="logs/$(date +%F)_backup.log"
# Append to the file
restic backup /etc/ 2>&1 >> $LOGFILE
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print 2>&1 >> $LOGFILE

And different commands behave differently, so it all starts to become complicated. But there's an easier way. Two actually. The first is to use curly brackets to contain all the commands you want to log, and then pipe it through tee at the end. Commands after that block won't be logged.

Read more

Mysql 8 mysql_native_password deprecation error. MY-013360

Checking in on a Mysql 8.x server the other day I found the following in the /var/log/mysql/error.log

[Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

But not just one of them. Lots and lots of them, one a second, for the last few months. To be sure it didn't seem critical, but having lots of crap in your logs means its obscuring the really important bits, and making it hard to detect real problems.

So how to get rid of them? Well not too hard as it happens. First option is to suppress them in your mysql config. I didn't know this was an option, but yes, you can add the following line to your mysqld config file and they don't get logged any more.

log_error_suppression_list='MY-013360'

Read more