当前位置:网站首页>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 !
边栏推荐
- 解决本地连接不上虚拟机的问题
- average-population-of-each-continent
- Basic knowledge of loop traversal and function
- 从学生到工程师的蜕变之路
- Go from introduction to practice -- definition and implementation of behavior (notes)
- Structured machine learning project (I) - machine learning strategy
- About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'
- Go from introduction to actual combat - task cancellation (note)
- Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
- 百万年薪独家专访,开发人员不修复bug怎么办?
猜你喜欢

渗透学习-sql注入过程中遇到的问题-针对sort=left(version(),1)的解释-对order by后接字符串的理解

Management system itclub (Part 1)

Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移
扁平数组和JSON树的转换

美团20k软件测试工程师的经验分享

Luogu p5706 redistributing fertilizer and house water

C # QR code generation and recognition, removing white edges and any color

7 jours d'apprentissage de la programmation simultanée go 7 jours de programmation simultanée go Language Atomic Atomic Atomic actual Operation contains ABA Problems

《7天学会Go并发编程》第六天 go语言Sync.cond的应用和实现 go实现多线程联合执行

Remote invocation of microservices
随机推荐
The "business and Application Security Development Forum" held by the ICT Institute was re recognized for the security capability of Tianyi cloud
Solve the problem that the virtual machine cannot be connected locally
真香,自从用了Charles,Fiddler已经被我彻底卸载了
管理系统-ITclub(上)
关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
This set of steps for performance testing using JMeter includes two salary increases and one promotion
Hash table - sum of arrays
Educational Codeforces Round 108 (Rated for Div. 2)
Is it safe to open a stock account through the account opening link given by the CICC securities manager? I want to open an account
OpenSSL Programming II: building CA
Typescript learning
渗透学习-靶场篇-dvwa靶场详细攻略(持续更新中-目前只更新sql注入部分)
Where can I set the slides on the front page of CMS applet?
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
Dynamic refresh mapper
MONTHS_ Between function use
How to do function test well? Are you sure you don't want to know?
Go language slice vs array panic: runtime error: index out of range problem solving
Dialogue with Qiao Xinyu: the user is the product manager of Wei brand, and zero anxiety defines luxury
【mysql实战】查询语句实战演示