当前位置:网站首页>Use logrotate to automatically cut the website logs of the pagoda
Use logrotate to automatically cut the website logs of the pagoda
2022-06-27 22:38:00 【jwj】
By default , Of the pagoda WEB When the software logs , Logs are not stored in different files by date , Long time logs are recorded in a file , It is very inconvenient to consult and manage .
One 、 install logrotate
Most of the Linux The system usually comes with logrotate, If it happens that your system doesn't come with , Sure stay github Download source code Build and install .
Or try to install directly with the command , for example :
- Red hat system (Red Hat):
yum install logrotateordnf install logrotate - ubuntu (Ubuntu):
sudo apt-get install logrotateorapt install logrotate
Two 、 principle
Actually “ cutting ” The two words are not correct , Let's briefly talk about the working principle of personal understanding .
1.logrotate Execution time , Files that meet the conditions set in the configuration will be processed .
2. Then rename the log file , And create a new log file .
3. Perform other operations , Such as : Compressed files .
3、 ... and 、 To configure
Create and edit a profile
sudo vim /etc/logrotate.d/btweblogsConfigure the content
/www/wwwlogs/*.log {
# Time interval between :daily= Every day /weekly= Once a week /monthly= monthly /yearly= Every year,
daily
# Number of copies to be retained , Old logs exceeding this number will be deleted automatically
rotate 14
# Ignore mistakes , Such as : file does not exist
missingok
# Rename file using date format
dateext
# Compress the separated files
compress
# Do not compress the files separated this time
delaycompress
# Ignore empty files ( That is, do not separate empty files )
notifempty
# Execute the script only once after multiple files are separated
sharedscripts
# Script executed after file separation
postrotate
# notice Nginx and Apache routine overloading
# Nginx
[ -e /www/server/nginx/logs/nginx.pid ] && kill -USR1 `cat /www/server/nginx/logs/nginx.pid`
# Apache
[ -e /www/server/apache/logs/httpd.pid ] && kill -USR1 `cat /www/server/apache/logs/httpd.pid`
endscript
}Four 、 end
logrotate In addition to the ability to separate compressed files , You can also send the separated files to the specified mailbox by mail , For specific methods, please refer to logrotate Manuals .
The pagoda itself also has a log cutting function , If there is no need for compression , You can use the functions of the pagoda .
Last, last , There's also a benefit . developers , Welcome to join Tengyun pioneer (TDP) Feedback communication group , There are plenty of activities in the group to gain points and growth value , Exchange for surprise benefits . How to join :https://cloud.tencent.com/developer/article/1855195
We are the vanguard of Tengyun (TDP) The team , Tencent cloud GTS Officially established and operated technology developer group . There are the most professional developers in & Customer , Be able to have close contact with product personnel , Proprietary questions & Demand feedback channels , There are a group of like-minded brothers and sisters , Looking forward to your joining !
边栏推荐
- The karsonzhang/fastadmin addons provided by the system reports an error
- C # QR code generation and recognition, removing white edges and any color
- MONTHS_ Between function use
- 爬虫笔记(2)- 解析
- Figure countdownlatch and cyclicbarrier based on AQS queue
- Dialogue with Qiao Xinyu: the user is the product manager of Wei brand, and zero anxiety defines luxury
- YOLOv6:又快又准的目标检测框架开源啦
- 读写分离-Mysql的主从复制
- xpath
- 爬虫笔记(3)-selenium和requests
猜你喜欢
![The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)](/img/e6/4eb2ddf4d9bac5e40bf2e96656d294.png)
The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)

登录凭证(cookie+session和Token令牌)

渗透学习-靶场篇-dvwa靶场详细攻略(持续更新中-目前只更新sql注入部分)

Système de gestion - itclub (II)

Remote invocation of microservices

AQS SOS AQS with me

使用sqlite3语句后出现省略号 ... 的解决方法

Crawler notes (1) - urllib

Windwos 8.1系统安装vmware tool插件报错的解决方法

渗透学习-sql注入过程中遇到的问题-针对sort=left(version(),1)的解释-对order by后接字符串的理解
随机推荐
MySQL greater than less than or equal to symbol representation
How many ways does selenium upload files? I don't believe you have me all!
Gbase 8A method for reducing the impact on the system by controlling resource usage through concurrency during node replacement of V8 version
About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'
go语言切片Slice和数组Array对比panic: runtime error: index out of range问题解决
Read write separation master-slave replication of MySQL
使用Fiddler模拟弱网测试(2G/3G)
Gbase 8A OLAP analysis function cume_ Example of dist
管理系统-ITclub(下)
Go language slice vs array panic: runtime error: index out of range problem solving
How to open an account for agricultural futures? How much is the handling charge for opening an account for futures? Who can give you a preferential handling charge?
Learn to go concurrent programming in 7 days go language sync Application and implementation of cond
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
CDH集群之YARN性能调优
Go from introduction to actual combat - task cancellation (note)
Crawler notes (1) - urllib
Ellipsis after SQLite3 statement Solutions for
Go from introduction to actual combat - execute only once (note)
Go from introduction to actual combat - only any task is required to complete (notes)
同花顺炒股软件可靠吗??安全嘛?