My first post, please be kind :)
I'm writing my first ever BASH script, and using systemd to invoke it on a timer (my first systemd units too!). The script runs backups daily, and uses notify-send to send Notifications to my Desktop.
I would like to direct some extra logging to journalctl, but only for some specific individual commands. I used 2>&1:
df -h | grep --color=never /mnt/Backups 2>&1
But when i do this, whether the backup succeeds or fails, the desktop notification via notify-send says "success" (systemd completes fine). I've tested removing the 2>&1 and notify-send gives me the correct notification advice of the Borg operations portion of the script (both success and fail were tested).
So - how do i start and then stop that redirection, have it show in journalctl, and have my notifications accurately displayed?
Here's that portion of my script:
df -h | grep --color=never /mnt/Backups 2>&1
SUCCESS=$?
echo $SUCCESS
## Use DESTOP Notifications.
if [ "${SUCCESS}" = "0" ]; then
notify-send -a Borg 'Operation was successful!' '~/.local/bin/borg-backup.sh' -u normal -i checkbox-checked-symbolic
else
notify-send -a Borg 'Operation was *NOT* successful' '~/.local/bin/borg-backup.sh' -u critical -i dialog-error
exit 1
fi
Thanks :)