The shell script implements all files in the upload directory to the server

Source: Internet
Author: User
Tags new set

Some time ago, the company has developed a new set of BSS system for foreign countries, one of which is to allow customers to upload documents, as well as I hold a photo of the document, the system this side of the manual review, but because China to foreign network is very slow, audit work abroad, and we upload end in China, So synchronous upload due to the network cause failure rate is very high, so you must make these files asynchronous upload, the development of the task pressure is too large, this function is not big, but change it will be very troublesome, so, helpless, with the operation of the method to deal with this problem, more nonsense, please see the script "rookie one, Please advise me if you have any problem, thank you very much ":



#!/bin/sh## #Warning: not modified## #Author: [email protected]## #Date: 2016-08-31export hostname= Host_nameexport home=/home/testuserexport shell=/bin/bashexport term=vt100export histsize= 1000export qtdir=/usr/lib64/qt-3.3export qtinc=/usr/lib64/qt-3.3/includeexport jre_home=${home} /java/jreexport user=testuserexport ld_library_path=:/usr/local/apr/libexport mail=/var/spool/ Mail/testuserexport java_home=${home}/javaexport lang=en_us. Utf-8host=ftp.host.or.ipuser=ftpuser.userpass=ftpuser.passwordremote_path=/home/ftpuser.user/busi_user_reg_img _uploadremote_path_his=/home/ftpuser.user/busi_user_reg_img_upload_hisremote_path_tmp=/home/ftpuser.user/busi_ User_reg_img_upload_tmplocal_path=${home}/important_imagelocal_path_his=${home}/important_image_hislocal_path_ tmp=${home}/important_image_tmpcount=0#----------------------------------------------------------------------- -------------------------------------------------------------------------------------#------------------------------------------------------------------------------ ------------------------------------------------------------------------------#--------------------cut  Line up is config down is program!---------------------------------------------- ---------------------------------------------------#----------------------------------------------------------- -------------------------------------------------------------------------------------------------#------------- --------------------------------------------------------------------------------------------------------------- --------------------------------cd ${home}alias cp= "cp" Start_time= ' date  "+%s" ' echo  " Start-----------------start-----------------start-----------------start-----------------start-----------------' Date ' "Mkdir -p ${local_path}mkdir -p ${local_path_his}mkdir -p ${local_path_tmp} For file in  ' find ${local_path} -maxdepth 1  -type f ' dofilename= ' basename  ${file} ' All_file_name= "${all_file_name} ${filename}" all_file= "${all_file} ${file}" echo  "$ {file} ... ... ... ... ... ... ... ... ... ... ... ... ... ... .... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... [Yes] "count= ' expr  $count  + 1 ' done# judgment ' find ${local_path} -maxdepth 1  - Type f '   command to search for eligible files if [[  $count  =  "0"  ]]; thenecho  "========== ============================no file find in folder ${local_path}!==================== ================== "elsetime_tag= ' date " +%y%m%d%h%m%s%n "' Mkdir -p ${local_path_tmp}/${time_tag} Mv ${all_file} ${local_path_tmp}/${time_tag}cd ${local_path_tmp}/${time_tag}ftp -v -n   ${host} <<enduser ${user} ${pass}cd ${remote_path}binprompt offmput  ${all_file_name}quitendcp -rf ${loCal_path_tmp}/${time_tag}/* ${local_path_his}rm -rf ${local_path_tmp}/${time_tag}end_time= ' Date   "+%s" ' seconds= ' expr  $END _time -  $START _time ' echo  ' ++++++++++++++++++++++++++++++++++ ++++++++++ftp_host:${host}   ftp_path:${remote_path}+++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++ "echo " #####################${seconds}s put to ftp ${count}  Files!!!! ############################################### "fiecho " Stop------------------Stop------------------stop------------------stop------------------stop-----------------' Date ' "Exit

Shell scripts implement all files in the upload directory to the server

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.