当前位置:网站首页>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 !
边栏推荐
- 01 golang environment construction
- Bean paste green protects your eyes
- Common problems encountered by burp Suite
- 登录凭证(cookie+session和Token令牌)
- 改善深层神经网络:超参数调试、正则化以及优化(三)- 超参数调试、Batch正则化和程序框架
- Use Fiddler to simulate weak network test (2g/3g)
- 读写分离-Mysql的主从复制
- 渗透学习-靶场篇-dvwa靶场详细攻略(持续更新中-目前只更新sql注入部分)
- Luogu p5706 redistributing fertilizer and house water
- regular expression
猜你喜欢

6G显卡显存不足出现CUDA Error:out of memory解决办法

average-population-of-each-continent

Luogu p5706 redistributing fertilizer and house water

解决本地连接不上虚拟机的问题

crontab定时任务常用命令

It smells good. Since I used Charles, Fiddler has been completely uninstalled by me

Infiltration learning - problems encountered during SQL injection - explanation of sort=left (version(), 1) - understanding of order by followed by string

Educational Codeforces Round 108 (Rated for Div. 2)

二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)

【Redis】零基础十分钟学会Redis
随机推荐
Selenium上传文件有多少种方式?不信你有我全!
二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)
Learn to go concurrent programming in 7 days go language sync Application and implementation of cond
Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"
A method of go accessing gbase 8A database
Go from introduction to practice - error mechanism (note)
The "business and Application Security Development Forum" held by the ICT Institute was re recognized for the security capability of Tianyi cloud
Summary of gbase 8A database user password security related parameters
Secret script of test case design without leakage -- module test
regular expression
Conversion between flat array and JSON tree
About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'
信通院举办“业务与应用安全发展论坛” 天翼云安全能力再获认可
Hash table - sum of arrays
01 golang environment construction
Go from introduction to practice -- shared memory concurrency mechanism (notes)
《7天学会Go并发编程》第7天 go语言并发编程Atomic原子实战操作含ABA问题
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
MONTHS_ Between function use
Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移