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 somedude@someplace.com < 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 term window, but 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 &> filenameto redirect both stdout and stderr to file namedfilename. – Michael Foukarakis Sep 24 '10 at 17:102>&1worked 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. – Karl Bielefeldt Sep 24 '10 at 17:19