1. Write a split script (splitNginxLog.sh) * Because this example sets the log splitting to be performed at 0:00 every day, folder and rq are both set to use yesterday's date for archiving. #!/bin/bash folder=`date -d yesterday +%Y%m` rq=`date -d yesterday +%Y%m%d` # Original log path logs_path="/var/log/nginx/sitename.com/" # Log backup path logs_backup_path="/var/log/nginx/sitename.com/$folder" # Logs to be split logs_access="access" logs_error="error" # Create a backup path [ -d $logs_backup_path ]||mkdir -p $logs_backup_path # Move the logs to the backup folder mv ${logs_path}${logs_access}.log ${logs_backup_path}/${logs_access}_${rq}.log mv ${logs_path}${logs_error}.log ${logs_backup_path}/${logs_error}_${rq}.log #Terminate nginx's pid pid_path="/var/run/nginx.pid" kill -USR1 $(cat $pid_path) 2. Test log splitting script Run the following statement in the directory where the .sh file is stored to test whether the split script is successful. If you get the error $'\r': command not found, it may be due to the encoding of the .sh file, because the script written in the Windows editor is slightly different from that in Linux. Treatment method: 1. Install dos2unix for encoding conversion 2. Convert code 3. Set up automatic execution
Write the following statements in it: The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief discussion on this.$store.state.xx.xx in Vue
>>: MySQL table auto-increment id overflow fault review solution
This article uses examples to explain the knowled...
Table of contents Preface 1. Tomcat class loader ...
Table of contents 1. Basic Use 2. Working Princip...
I re-read the source code of the Fabric project a...
After a long period of transplantation and inform...
This article introduces a detailed explanation of...
There is a simple CSS method to realize the pop-u...
Web design and development is hard work, so don...
Many friends who have just started to make web pag...
Table of contents 1. What is vuex 2. Installation...
1. Network Optimization YSlow has 23 rules. These...
1. The color of the scroll bar under xhtml In the ...
There is a table student in the mysql database, i...
This article describes the MySQL integrity constr...
Table of contents 1. Introduce cases 2. View the ...