FTP automatic upload

Source: Internet
Author: User

FTP automatic upload

In the past two days, my boss told me to download the logs on the linux server and read the log files on the server. The logs are also small and backed up once a day. I thought, another troublesome thing. I thought about it later. Why don't I use shell scripts and cron scheduling directly? This saves a lot of trouble and I checked the method online, hey hey, I was excited to find that ftp could not be used for interaction .... Add the ftp command to the shell script to implement the upload and then use cron scheduling to execute it. Everything is done!

The main difficulty is to use an ftp client in shell to upload log files to the server. Of course, you must first set up an ftp server and enable the server during cron scheduling.

Shell code

#! /Bin/bash

Ftp-n 10.1.13.36 21 <CMDS

User admin // the user name and password are the two following: plaintext, insecure

LCD/var/log // switch to the directory to be uploaded. Do not write the path directly on put. This is not acceptable.

Put messages

Bye // exit ftp

TAG

In addition to cron scheduling, write it by yourself. Everything is OK. You only need to check the ftp server every day.

Note: If the code is executed separately, there may be a warning, but it does not affect the upload. If you do not want to receive a warning, you only need to add the-u parameter to ftp-n 10.1.13.36 21 <CMDS, that is, ftp-u-n10.1.13.36 21 <CMDS, but note that after-u is added, scheduling may not be executed, and a message is displayed without the-u parameter, therefore, we recommend that you do not use the-u parameter.


This article from "guo understands blog" blog, please be sure to keep this source http://guodong810.blog.51cto.com/4046313/1303562

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.