I run the following file with the > log.log
redirector, and it does not capture errors.
#!/bin/bash
echo ************************BEGIN LOG******************************
date +"%m/%d/%Y %H:%M:%S $HOSTNAME"
cp -f /scripts/original/clamscans.log /scripts
find /public/public/clamscans/. -exec grep -n FOUND /dev/null {} \;>>clamscans.log
mail [email protected] < clamscans.log
tar cvf dailyresults.tar /public/public/clamscans/*.txt
gzip -f dailyresults.tar
mv -f /public/public/clamscans/*.txt /scripts/lastnite
echo end log entry
The following errors show up when I run from the file from the terminal window, but they are not written to log.log
:
tar: /public/public/clamscans/*.txt: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
mv: cannot stat `/public/public/clamscans/*.txt': No such file or directory
What am I doing wrong? I know with Windows you can add the 2>&1
to capture error data. Is there such a thing for Linux?
command &> filename
to redirect both stdout and stderr to file namedfilename
.2>&1
worked on windows, so I thought I read the question wrong at first. Moral of the story: sometimes the equivalent in the other OS is identical.