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