This is my first attempt at BASH and I have a little problem. The purpose of this script is to clear the ZFS pools and create a log file.
The code works as intended, with the exception of line 19 below. (LogEntry $ LOG_LINE). I added line 18 for debugging purposes and it works.
Line 18 writes that the βpoolβ tank is βhealthyβ for the magazine, and line 19 only βpoolβ. Functionally, this line does the same (at least before my eyes), so why should one work and not the other.
I assume that the root case is the quote before the pool name in the output of the zpool status command, and I am working on replacing the char for this, but I would like to understand how these two lines are interpedited differently.
Thanks in advance Declan
#!/bin/bash LOG_FILE=/home/declan/log/zfs_scrub LOG_LAST=/home/declan/log/zfs_scrub_last function LogEntry { echo -e "$(date "+%Y %m %d %T") ; $1" >>$LOG_FILE 2>&1 } cp $LOG_FILE $LOG_LAST rm $LOG_FILE LogEntry "Starting ZFS Scrub" for POOL in $(zpool list -H -o name) ; do LogEntry "Starting Scrub on $POOL" zpool scrub $POOL 2>/dev/null LOG_LINE=$(zpool status -x $POOL 2>&1) echo -e "$(date "+%Y %m %d %T") ; $LOG_LINE" >>$LOG_FILE 2>&1 LogEntry $LOG_LINE LogEntry "Ending Scrub on $POOL" done LogEntry "Ending ZFS Scrub"
source share