First, FTP download the current file according to the date
#!/bin/bashdate= ' Date +%y%m%d ' ftp-n <<!open 192.168.10.14user zzx [email protected]binarylcd/opt/zzxpromptmget bj.log-$date. Txtclosebye
Second, upload the current file according to the log
#!/bin/bashdate= ' Date +%y%m%d ' ftp-n <<!open 192.168.10.14user zzx [email protected]binarylcd/opt/zzxpromptmput bj.log-$date. txt//mput upload file Closebye
Three, more and catalog upload download
#!/bin/bashdate= ' Date +%y%m%d ' ftp-n <<!open 192.168.10.14user zzx [email protected]binarycd/onelcd/opt/ Zzxpromptmput bj.log-$date. Txtcd/twolcd/opt/zzxmput bj.log-$date. txtclosebye!
Iv. Multiple and directory log integration
#!/bin/bashdate= ' Date +%y%m%d ' One=/opt/log/coutlogs/zzxweb1/201511two=/opt/log/coutlogs/zzxweb2/201511gunzip $ one/bj.log-$date. Gzgunzip $two/bj.log-$date. gztouch/opt/tiandaolog/count/bj.log-$dateNewLog =/opt/bj/countfor Log In bj.log-$date do sort-m-T "" K 4-o $NewLog/$log $one/$log $two/$logdone
Summary: Save the above script as a file added to the crontab can be implemented automatically ftp upload, download files.
notes:
1.-N is not affected by the. netrc file. (FTP defaults to read the settings in the. netrc file)
2. << is using instant file redirection input.
3.! is the instant file flag it must appear in pairs to identify the start and end of the instant file.
Shell performs FTP action and log merge