#!/bin/ksh
filedate=`date +"20%y%m%d"`
myhost=`hostname`
errlog=/tmp/fixmv/stdout.log
exec 2>$errlog 1>&2
echo "error log will list here, if empty means there is no error log"
cd /TFT/1IL/CHAR
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/1IL/CHAR/$filedate
cd /TFT/3IL/CHAR
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/3IL/CHAR/$filedate
cd /TFT/AT1/CHAR
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/AT1/CHAR/$filedate
cd /TFT/FR1/CHAR
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/FR1/CHAR/$filedate
cd /TFT/FCV/CHAR
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/FCV/CHAR/$filedate
cd /TFT/1IL/JPG/IMAGE
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/1IL/JPG/IMAGE/$filedate
cd /TFT/3IL/JPG/IMAGE
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/3IL/JPG/IMAGE/$filedate
cd /TFT/AT1/JPG/MAP
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/AT1/JPG/MAP/$filedate
cd /TFT/FR1/JPG/IMAGE
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/FR1/JPG/IMAGE/$filedate
cd /TFT/FCV/JPG/IMAGE
find ./ -mtime +4 -print|cut -c3-100|xargs -I {} mv {} /BKFILE/FCV/JPG/IMAGE/$filedate
mail -s "$myhost fixmove error log!" mymail@myserver.com rm /tmp/fixmv/stdout.log
exit 0
注意这地方
errlog=/tmp/fixmv/stdout.log
exec 2>$errlog 1>&2
本来,如果没有这一段 mv文件的时候会有很多错误,如果没有重定向错误输出,默认的话会输出到屏幕
这样我们在执行脚本时就无法看到错误输出了(放在crontab里面用),使用exec修改了stdout,stderr后可
以将脚本里面所有命令执行时的错误输出存到我们指定的文件里面!
阅读(2277) | 评论(0) | 转发(0) |