当前位置:网站首页>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 !
边栏推荐
- About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'
- Ellipsis after SQLite3 statement Solutions for
- 管理系统-ITclub(下)
- 中金证券经理给的开户链接办理股票开户安全吗?我想开个户
- Acwing week 57 longest continuous subsequence - (binary or tree array)
- Introduction to ARCS Model
- Example of using gbase 8A OLAP function group by grouping sets
- gomock mockgen : unknown embedded interface
- The karsonzhang/fastadmin addons provided by the system reports an error
- Penetration learning - shooting range chapter -dvwa shooting range detailed introduction (continuous updating - currently only the SQL injection part is updated)
猜你喜欢

Figure countdownlatch and cyclicbarrier based on AQS queue

AQS SOS AQS with me

Go from introduction to actual combat - task cancellation (note)

九九乘法表——C语言

Penetration learning - shooting range chapter - detailed introduction to Pikachu shooting range (under continuous update - currently only the SQL injection part is updated)

Codeforces Round #716 (Div. 2)

Learn to go concurrent programming in 7 days go language sync Application and implementation of cond

CUDA error:out of memory caused by insufficient video memory of 6G graphics card

Go from introduction to practice -- definition and implementation of behavior (notes)

二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)
随机推荐
Login credentials (cookie+session and token token)
Go from introduction to practice -- definition and implementation of behavior (notes)
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
结构化机器学习项目(一)- 机器学习策略
Experience sharing of meituan 20K Software Test Engineers
Crontab scheduled task common commands
Penetration learning - shooting range chapter -dvwa shooting range detailed introduction (continuous updating - currently only the SQL injection part is updated)
从学生到工程师的蜕变之路
哈希表-数组之和
对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华
Common problems encountered by burp Suite
對話喬心昱:用戶是魏牌的產品經理,零焦慮定義豪華
《7天學會Go並發編程》第7天 go語言並發編程Atomic原子實戰操作含ABA問題
《7天学会Go并发编程》第六天 go语言Sync.cond的应用和实现 go实现多线程联合执行
Go from introduction to practice -- shared memory concurrency mechanism (notes)
Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
Day8 - cloud information project introduction and creation
Common APIs (Methods) for scope -number and string
Secret script of test case design without leakage -- module test
Basic data type and complex data type