定时每天从数据库中取出记录存成文本文件上传ftp服务器的例子
year=`date +%Y`
mon=`date +%m`
day=`date +%d`
day=`expr $day - 2`
if [ $day -eq 0 ]
then
mon=`expr $mon - 1`
if [ $mon -eq 0 ]
then
mon=12
year=`expr $year - 1`
fi
lastline=`cal $mon $year | grep "[0-9]" | tail -1`
day=`echo $lastline | sed "s/.* \([0-9][0-9]*\)/\1/"`
fi
if [ ${#mon} -eq 1 ]
then
mon="0$mon"
fi
if [ ${#day} -eq 1 ]
then
day="0$day"
fi
dat="$year$mon$day"
filename="main_error_detail$dat.txt"
echo $filename
cd /home/ PLATFORM/config/upload
sqlplus
devuser/trusttrans@unpfdb <<eof
@upload.sql $filename
exit
eof
echo $dat
ftp -n<<!
open 85.0.81.106
user irmsebk irmsebk
bin
hash
prompt
put $filename
close
bye
!
ftp -n<<!
open 85.0.81.107
user irmsebk irmsebk
bin
hash
prompt
put $filename
close
bye
!