Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to upload log to other servers regularly using ftp

Shulou Source: shulou.com Published: 2022-06-01 12:23:46 11月12日 Update

This article mainly introduces "how to use ftp timing upload log to other servers", in daily operation, I believe many people in how to use ftp timing upload log to other servers on the problem there are doubts, small make up consult all kinds of information, sort out simple and easy to use operation method, hope to answer everyone "how to use ftp timing upload log to other servers" doubts helpful! Next, please follow the small series to learn together!

Upload logs to other servers regularly using ftp

#!/ bin/bash

#Generation of time

Y=` date --date="-1 hour" +%Y`

m=` date --date="-1 hour" +%m`

d=`date --date="-1 hour" +%d`

H=`date --date="-1 hour" +%H`

#IP address acquisition

IP="`/sbin/ifconfig |grep 'Bcast'|awk -F '[ :]' '{print $13}'`"

#log name generation (varies with time and ip)

LOG_NAME="access-$H-$IP.log"

#FTP Server Address

HOST="10.10.10.170"

#FTP Server User Name

USER="user"

#FTP Server Password

PASS="passwd"

#Upload log files for different projects cyclically

for ROUTE_NAME in "www_log" "h_log" "lpt_log" "c_log" ;do

LCD="/usr/local/nginx/logs/$ROUTE_NAME/$Y/$m/$d"

RCD="/$ROUTE_NAME/$Y/$m/$d"

if [ -f $LCD/$LOG_NAME ] ;then

lftp

Tags: Server service learning different address file time more help generation utility next name password article method log theory user user name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno Docker Apple Huawei