This is script. None of the echo lines display(?).
#!/bin/bash
LOGFILE="$HOME/myth_backup.log" TARGET="/media/alan/e06b3828-2ec7-493a-bfbc-dcdd04ac2fed"
echo "Backup started at $(date)" >> "$LOGFILE"
# Run MythTV backup
#
echo "Running mythconverg_backup.pl..." >> "$LOGFILE" /home/mythtv/mythconverg_backup.pl >> "$LOGFILE" 2>&1 || \
echo "WARNING: mythconverg_backup.pl failed" >> "$LOGFILE"
# Rsync backup
echo "Starting rsync..." >> "$LOGFILE"
if mountpoint -q "$TARGET"; then
if rsync -avh --delete /home/mythtv/ "$TARGET"/ >> "$LOGFILE" 2>&1; then
echo "Backup completed successfully at $(date)" >> "$LOGFILE"
else
echo "ERROR: rsync failed at $(date)" >> "$LOGFILE"
fi
else
echo "ERROR: Backup target not mounted, skipping rsync" >> "$LOGFILE"
fi
TIA Alan
On 5/2/26 3:13 PM, pinnerite wrote:
This is script. None of the echo lines display(?).First, how are you running this? Clicking on the shell script via Nemo, running from a
#!/bin/bash
LOGFILE="$HOME/myth_backup.log"
TARGET="/media/alan/e06b3828-2ec7-493a-bfbc-dcdd04ac2fed"
echo "Backup started at $(date)" >> "$LOGFILE"
# Run MythTV backup
#
echo "Running mythconverg_backup.pl..." >> "$LOGFILE"
/home/mythtv/mythconverg_backup.pl >> "$LOGFILE" 2>&1 || \
echo "WARNING: mythconverg_backup.pl failed" >> "$LOGFILE"
# Rsync backup
echo "Starting rsync..." >> "$LOGFILE"
if mountpoint -q "$TARGET"; then
if rsync -avh --delete /home/mythtv/ "$TARGET"/ >> "$LOGFILE" 2>&1; then
echo "Backup completed successfully at $(date)" >> "$LOGFILE"
else
echo "ERROR: rsync failed at $(date)" >> "$LOGFILE"
fi
else
echo "ERROR: Backup target not mounted, skipping rsync" >> "$LOGFILE" >> fi
TIA Alan
cron job, running from a terminal window from the command line?
I know it's stupid but put all your variables in {} ${LOGFILE} etc.
Try shellcheck on the script. shellcheck <full path of script>
You can capture errors >logfile.txt if it's a lot.
This is script. None of the echo lines display(?).
#!/bin/bash
LOGFILE="$HOME/myth_backup.log" TARGET="/media/alan/e06b3828-2ec7-493a-bfbc-dcdd04ac2fed"
echo "Backup started at $(date)" >> "$LOGFILE"
# Run MythTV backup
#
echo "Running mythconverg_backup.pl..." >> "$LOGFILE" /home/mythtv/mythconverg_backup.pl >> "$LOGFILE" 2>&1 || \
echo "WARNING: mythconverg_backup.pl failed" >> "$LOGFILE"
# Rsync backup
echo "Starting rsync..." >> "$LOGFILE"
if mountpoint -q "$TARGET"; then
if rsync -avh --delete /home/mythtv/ "$TARGET"/ >> "$LOGFILE" 2>&1; then
echo "Backup completed successfully at $(date)" >> "$LOGFILE"
else
echo "ERROR: rsync failed at $(date)" >> "$LOGFILE"
fi
else
echo "ERROR: Backup target not mounted, skipping rsync" >> "$LOGFILE"
fi
TIA Alan
This is script. None of the echo lines display(?).
Let us work with this one.
somecommand >> "$LOGFILE" 2>&1
That says to redirect "stderr" to "stdout",
then redirect "stdout" additively to the $LOGFILE.
Nowhere does it mention anything about also
including a copy on Alans Screen :-)
How about if we try this ?
somecommand 2>&1 | tee >> "$LOGFILE"
Paul wrote:
Let us work with this one.
somecommand >> "$LOGFILE" 2>&1
That says to redirect "stderr" to "stdout",
then redirect "stdout" additively to the $LOGFILE.
Nowhere does it mention anything about also
including a copy on Alans Screen :-)
How about if we try this ?
somecommand 2>&1 | tee >> "$LOGFILE"
I think you need:
somecommand 2>&1 | tee --append "$LOGFILE"
Otherwise you're redirecting the copy that tee sends to stdout to the
file instead (so you still won't get any output on the terminal), and
not giving tee any files to copy it to.
--
Mark.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 4 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 495145:27:52 |
| Calls: | 165 |
| Files: | 574 |
| D/L today: |
29 files (9,998K bytes) |
| Messages: | 78,198 |