Linux remote file copy

Source: Internet
Author: User
Tags scp file
Linux remote file copy Shell code www.2cto.com #! /Bin/sh #################################### ######################################## ######### put/data/sea/upload/bottom text on the 10.0.64.20.host
Linux remote file copy Shell code www.2cto.com #! /Bin/sh #################################### ######################################## ######### copy the file under/data/sea/upload/on the 10.0.64.20.host to 10.10.31.79 ############## ##### after the file is successfully copied, delete the file from the 10.0.64.20.host, local operation log #################################### ######################################## ################# remote host address remote_ip = 10.0.64.20; # remote host login user remote_user = root; # remote host directory remote_path = "/data/sea/upload"; # save locally Remote Copy file directory local_path = "/usr/data/upload/ftpupload"; # Local log file output directory log_dir = "/home/web_sea/logs "; log_file_date = 'date + % f'; for file in 'Ssh $ {remote_ip} ls $ {remote_path} 'do scpfile = "scp $ {remote_user }@$ {remote_ip }: $ {remote_path}/$ {file }$ {local_path}/"; $ scpfile; log_date = 'date + % F" "% t'; if [$? -Eq 0]; then echo "$ log_date debug scp file [$ file] is successfully" >>$ log_dir/access _ $ {log_file_date }. log ssh $ {remote_ip} rm-rf $ {remote_path}/$ {file} if [$? -Eq 0]; then echo "$ log_date debug delete file [$ file] is successfully" >>$ log_dir/access _ $ {log_file_date }. log else echo "$ log_date error delete file [$ file] is failure" >>$ log_dir/error _ $ {log_file_date }. log fi else echo "$ log_date error scp file [$ file] is failure" >>$ log_dir/error _ $ {log_file_date }. log fi done
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.