1, configure multiple server logs as long as the $website variable is incremented and separated by a space.
2, looping to create the log directory
3, after the split with XZ compression, of course, can not be installed with Gzip bzip2 and so on.
4, note that I configure the Nginx log file named "access_{{site}}.log" "error_{{Site site}}.log"
Copy Code code as follows:
#!/usr/bin/bash
Log_dir= "/usr/local/nginx/logs"
Back_log_dir= "/disk110/nginx_log"
Time= ' Date +%y%m%d-%h:%m:%s '
Website= "www.test1.com www.test2.com www.test3.com";
For I in $website
Todo
if [!-D ${back_log_dir}/${i}]
Then
mkdir ${back_log_dir}/${i}
Fi
Done
For I in $website
Todo
If [-S ${log_dir}/access_${i}.log]
Then
MV ${log_dir}/access_${i}.log ${back_log_dir}/${i}/access_${time}.log
Fi
If [-S ${log_dir}/error_${i}.log]
Then
MV ${log_dir}/error_${i}.log ${back_log_dir}/${i}/error_${time}.log
Fi
Done
KILL-USR1 ' Cat/usr/local/nginx/logs/nginx.pid '
For I in $website
Todo
If [-S ${back_log_dir}/${i}/access_${time}.log]
Then
XZ ${back_log_dir}/${i}/access_${time}.log
Fi
If [-S ${back_log_dir}/${i}/error_${time}.log]
Then
XZ ${back_log_dir}/${i}/error_${time}.log
Fi
Done