IT运维笔记


linux下ftp自动登录的shell脚本

FTP自动登录并批量下载

#!/bin/bash
mkdir /bak/`date +%Y%m%d`

ftp -n<<!
open 192.168.1.10
user ftpuser ftppass
binary
cd pro_bak
lcd /bak/`date +%Y%m%d`
prompt
mget *
mdelete *
close
bye
!

chown test /bak/*
chown test /bak/`date +%Y%m%d`/*

FTP自动登录并上传文件

#!/bin/bash
tar -czvf /bak/tomcat_bak_`date +%Y%m%d%H%M`.tar.gz /tomcat --exclude=/tomcat/logs

ftp -n<<!
open 192.168.1.10
user ftpuser ftppass
binary
cd pro_bak
lcd /bak
prompt
put tomcat_bak_*
close
bye
!

rm -rf tomcat_bak_*