Lico_w
asked on
Unix BASH Scripting - Crontab output to file
I have a script which runs weekly on my crontab (see below) but would like to output results to file, how would I do this?
I tried including this option pointing to a txt file but didn't seem to work:
2>&1 >
I tried including this option pointing to a txt file but didn't seem to work:
2>&1 >
#!/usr/bin/ksh
#Alert log tidy script
logDir="/bea_domains/config/AHE_CIT/logs"
tempDir="/tmp/alertLogArchive"
date=`date +%Y%m%d`
archiveDir="/bea_domains/config/AHE_CIT/logs/archive"
mkdir $tempDir
cd $logDir
find . -name "*alert.log*" -type f -mtime +30 -exec mv '{}' $tempDir \;
tar cvf - ${tempDir}/* | gzip > ${archiveDir}/alertlog_archive.${date}.tar.gz
rm -fr $tempDir
cd $archiveDir
find . -name "alertlog_archive*" -type f -mtime +60 -exec rm {} \;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The second solution will give no output at all and you won't receive any email either. Is this what you desire?
Thx for the points anyway.
wmp
Thx for the points anyway.
wmp
Note that
cmd 2>&1 >file
will not produce the same results as
cmd >file 2>&1
cmd 2>&1 >file
will not produce the same results as
cmd >file 2>&1
ASKER