当前位置: 首页 > news >正文

网站建设入什么费用东莞头条最新新闻

网站建设入什么费用,东莞头条最新新闻,wordpress 图片 自动重mingming,2024年新闻摘抄十条linux日志管理工具logrotate配置logrotate介绍logrotate配置讲解主配置文件解释(/etc/logrotate.conf)logrotete 命令参数添加配置以添加一个nginx配置为例强制启动配置logrotate介绍 logrotate是centos自带工具,其他操作系统可能需要自行安装。logrotate用来进行日…

linux日志管理工具logrotate配置

  • logrotate介绍
  • logrotate配置讲解
  • 主配置文件解释(/etc/logrotate.conf)
  • logrotete 命令参数
  • 添加配置
  • 以添加一个nginx配置为例
  • 强制启动配置

logrotate介绍

logrotate是centos自带工具,其他操作系统可能需要自行安装。logrotate用来进行日志切割和定期删除。
logrotate通过简单配置,帮助我们实现日志切割,以及对久远日志的删除,从而避免单个日志文件过大,以及众多的日志文件占用存储空间。

logrotate配置讲解

logrotate是基于crond服务(定时任务)来运行的

/etc/logrotate.conf(主配置)和/etc/logrotate.d/*(子配置)

/etc/logrotate.conf为全局配置,在logrotate.conf中包含:include /etc/logrotate.d,用于加载子配置文件,/etc/logrotate.d/目录下为具体配置,一般以服务名称命名,比如nginx,mysql,yum等,
当主配置和子配置有冲突时,以子配置的规则为准。

主配置文件解释(/etc/logrotate.conf)

cat /etc/logrotate.conf
#文件内容如下


# see "man logrotate" for details
# rotate log files daily
#所有的日志文件,每天滚动一次
daily# keep 4 daily worth of backlogs
#日志发生滚动后,指定备份日志文件保存多少个副本(权限不变)
rotate 4# create new (empty) log files after rotating old ones
#是否创建一个空的新的日志文件
create# use date as a suffix of the rotated file
#指定滚动文件的后缀是当前日期
dateext# uncomment this if you want your log files compressed
#是否对滚动后的日志进行压缩
#compress# RPM packages drop log rotation information into this directory
#加载子配置文件
include /etc/logrotate.d#######以下是两个子配置
# no packages own wtmp and btmp -- we'll rotate them here
#指定对特定的日志文件的滚动规则
/var/log/wtmp {monthly                 #一月滚动一次create 0664 root utmp   #指定滚动后创建的新文件的权限为0644,数组为root,属组为utmpminsize 1M             #指定文件的值小于1M不滚动   rotate 1                #指定保留几个备份副本}/var/log/btmp {missingok   #如果日志文件不存在发送错误消息monthlycreate 0600 root utmprotate 1}

logrotete 命令参数

logrotate [-dv] [-f|--force] [-s|--state file] config_file...
-d显示配置过程
-f强制启动logrotate
-s使用指定的状态文件
config_file具体的配置文件

添加配置

基于原有的配置新增(主配置或者子配置)
这种方式是基于计划任务:/etc/cron.daily/logrotate

[root@local logrotate.d]# cat /etc/cron.daily/logrotate
#!/bin/sh/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

该定时任务使用主配置文件,主配置文件中又包含了/etc/logrotage.d/中的子配置
所以在主配置文件中添加或者子配置文件夹中添加配置均可

以添加一个nginx配置为例

cd /etc/logrotate.d/
vi nginx

添加如下内容

/usr/local/nginx/logs/*.log {daily# 每天轮询rotate 7# 最多保存七个文件nocompress# 对切割后的日志文件不进行压缩copytruncate# 用于还在打开中的日志文件,把当前日志备份并截断missingok# 如果日志不存在,不提示错误,继续处理下一个dateext# 使用日期作为日志轮替文件的后缀,如secure-20130605dateformat.%Y-%d-%m# 格式化日志文件名称sharedscripts# 在此关键宇之后的脚本只执行一次postrotateif [ -f /usr/local/nginx/sbin/nginx-tengine.pid ]; thenkill -USR1 `cat /usr/local/nginx/sbin/nginx-tengine.pid`fiendscript
}

强制启动配置

logrotate  -vf nginx
[root@local logrotate.d]# logrotate -vf nginx 
reading config file nginx
Allocating hash table for state file, size 15360 BHandling 1 logsrotating pattern: /usr/local/nginx/logs/*.log  forced from command line (7 rotations)
empty log files are rotated, old logs are removed
considering log /usr/local/nginx/logs/access.loglog needs rotating
considering log /usr/local/nginx/logs/error.loglog needs rotating
rotating log /usr/local/nginx/logs/access.log, log->rotateCount is 7
Converted '.%Y-%d-%m' -> '.%Y-%d-%m'
dateext suffix '.2023-07-03'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
rotating log /usr/local/nginx/logs/error.log, log->rotateCount is 7
Converted '.%Y-%d-%m' -> '.%Y-%d-%m'
dateext suffix '.2023-07-03'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
copying /usr/local/nginx/logs/access.log to /usr/local/nginx/logs/access.log.2023-07-03
truncating /usr/local/nginx/logs/access.log
copying /usr/local/nginx/logs/error.log to /usr/local/nginx/logs/error.log.2023-07-03
truncating /usr/local/nginx/logs/error.log
running postrotate script

执行命令之后出现如上信息,并且在nginx日志目录增加了日志的轮替文件如下:

access.log  access.log.2023-07-03  error.log  error.log.2023-07-03  

其中带日期后缀的,就是轮替日志文件。

http://www.hkea.cn/news/432505/

相关文章:

  • 长春网站建设硕成传媒seo快速排名优化公司
  • web网站开发能使用c 吗免费建立个人网站申请
  • 织梦网站修改教程视频网站优化培训学校
  • 南沙区交通和建设局网站中国十大网络销售公司
  • 免费建设网站的方法百度网址大全 官网
  • 手机网站设计制作公司微信推广费用一般多少
  • 建设网站需要什么注册域名费用一般多少钱
  • 女性门户网站源码百度指数功能有哪些
  • 怎么帮公司做网站建设谷歌搜索引擎免费入口 香港
  • 请写出网站建设前期需要做的准备外贸定制网站建设电话
  • 南京门户网站建设网络营销优秀案例
  • 2012服务器如何做网站周口网络推广哪家好
  • 贵阳搜索玩的网站网络舆情软件免费入口
  • 前端自己写代码建网站要花多少钱游戏推广在哪里接活
  • 网站建设中+网页代码nba最新排名东西部
  • 东莞企业建设网站官网有限公司百度推广深圳分公司
  • 海外推广工作内容搜索引擎优化seo是什么
  • wordpress 发短信西安网络优化大的公司
  • dreamweaver个人网站南宁求介绍seo软件
  • 网站常用素材企业培训视频
  • 北京市通州区建设委员会网站网站新站整站排名
  • 太原网站推广只选中联传媒推广排名seo
  • 企业网站建设的常见流程为百度互联网营销顾问
  • 养殖企业网站网络营销策划名词解释
  • 如何进行电子商务网站推广?百度网盘app
  • 做情趣网站需要什么资质sem推广外包
  • 国外网站做任务赚钱的最近新闻有哪些
  • 建设部网站查资质中裕隆百度推广登录平台网址
  • 黄页网站大全免费山东网络推广优化排名
  • 网站文字代码常见的网络营销工具