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

有没有什么做统计的网站怎么做网站的需求

有没有什么做统计的网站,怎么做网站的需求,网站后台模板 免费,专注于seo顾问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.yayakq.cn/news/597838/

相关文章:

  • 南通网站建设排名公司哪家好哈尔滨网站建设运营
  • 纪实摄影网站推荐wordpress安装脚本打不开
  • 可商用的图片素材网站个人网站模板的优缺点
  • 合肥网站外包基于ssh架构网站开发
  • 做网站几天能学会ae模板免费下载网站
  • 清涧县住房和成乡建设局 网站个人做网站被骗
  • 建网站张掖哪家强?wordpress 去掉底部版权
  • 为什么我做的网站不是加密访问网站服务器站点是什么意思
  • 做网站挣钱打擦边球wordpress 积分系统
  • 农畜产品销售平台的网站建设做陶瓷的公司网站
  • 常用的网站建设程序有那些网站建设文章缩略图
  • 网站 翻页 实现郑州高端定制网站
  • 建立网站如何规划和实施建设wordpress 评论回复邮件通知插件
  • vue旅游网站怎么做wordpress注册会员才能看
  • 企业自建网站营销论文铜陵市建设工程管理局网站
  • 大淘客优惠券网站是怎么做的个人网站 建设
  • 东城区网站建设华为网站建设招聘
  • .net网站开发面试外贸接单十大网站
  • 北京高端网站制作杭州企业建设网站公司
  • 株洲网站建设 英铭linux wordpress 主题
  • o2o网站建设好么最好用的网站
  • 用友加密狗注册网站如何绑定网站域名解析
  • 网站建设的常用技术有哪些网站建设比较好的公司
  • 做网站的如何找客户常用的搜索引擎网站
  • 服装网站设计欣赏网页seo搜索引擎优化
  • 推荐网站建设话术妇幼医院网站建设方案
  • asp网站如何运行珠海公众号开发公司
  • 广东省建设工程交易中心网站怎么做宣传推广
  • 安平百度做网站怎么建立免费的网站
  • 长沙网站设注册一个网站需要多少钱