How to upload log to other servers regularly using ftp
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