Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to upload log to other servers regularly using ftp

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report