Issue with stderr redirect in csh script

Hi all,

I am using a csh script to backup to multiple restic repos. The script logs the output of the restic command and the return code, such that I can receive a notification in case something went wrong. For some reason the log only contains the stdout output, but not the stderr. The command I run looks like this:

restic backup --verbose --tag periodic $BACKUP_PATHS >& backup.log

I had the suspician, that it might have something todo with the interactive output of restic, but I could not find any thread that mentions this exact issue. Am i doing something wrong with the redirect?

Using csh the >& should merge both the stdout and stderr and put them into the backup.log file. The links below suggest that csh does not have an easy way to put the stdout to one file and stderr to another file.
https://stackoverflow.com/questions/32010883/redirecting-stderr-in-csh
https://stackoverflow.com/questions/13720246/redirect-stderr-to-stdout-in-c-shell
Some may suggest changing from csh to another shell such as bash. Hope this helps.

1 Like