<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>系统运维 &#187; Mongodb数据库日志</title>
	<atom:link href="http://www.osyunwei.com/archives/tag/mongodb%e6%95%b0%e6%8d%ae%e5%ba%93%e6%97%a5%e5%bf%97/feed" rel="self" type="application/rss+xml" />
	<link>https://www.osyunwei.com</link>
	<description>国产化OS/AnolisOS/openEuler/RHEL/CentOS/Rocky Linux/Debian/Ubuntu Linux FreeBSD 服务器教程 &#124; Windows Server 2003/2008/2012/2016/2019/2022/2025服务器教程</description>
	<lastBuildDate>Sun, 10 May 2026 14:53:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux下定时切割Mongodb数据库日志并删除指定天数前的日志记录</title>
		<link>https://www.osyunwei.com/archives/8998.html</link>
		<comments>https://www.osyunwei.com/archives/8998.html#comments</comments>
		<pubDate>Sat, 28 Feb 2015 06:17:55 +0000</pubDate>
		<dc:creator>qihang01</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Mongodb数据库日志]]></category>

		<guid isPermaLink="false">http://www.osyunwei.com/?p=8998</guid>
		<description><![CDATA[说明： 操作系统：CentOS Mongodb安装目录：/usr/local/mongodb Mongodb数据库存放目录：/home/data/mongodb/mongodb_data Mongodb日志存放目录：/home/data/mongodb/mongodb_log 实现目的： 对Mongodb数据库日志按天保存，并且只保留最近7天的日志记录。 具体操作： 使用Mongodb数据库自带的命令来切割日志 ps -def &#124; grep mongod kill -SIGUSR1 &#60;mongod process id&#62; 1、创建Mongodb数据库日志切割脚本 vi /home/crontab/cut_mongodb_log.sh #编辑 #!/bin/sh datafile=/home/data/mongodb/mongodb_data #Mongodb数据库存放目录 logfile=/home/data/mongodb/mongodb_log #Mongodb日志存放目录 days=7 #代表删除7天前的备份，即只保留最近7天的备份 /bin/kill -SIGUSR1 `cat $datafile/mongod.lock` #切割日志 find $logfile/ -mtime +$days -delete #删除7天前的备份文件 :wq! #保存退出 chmod +x   /home/crontab/cut_mongodb_log.sh  #添加执行权限 系统运维 www.osyunwei.com 温馨提醒：qihang01原创内容©版权所有,转载请注明出处及原文链接 2、添加任务计划，修改/etc/crontab vi /etc/crontab #在最后一行添加 0 [...]<p><a rel="bookmark" href="https://www.osyunwei.com/archives/8998.html" target="_blank">查看全文</a></p>]]></description>
		<wfw:commentRss>https://www.osyunwei.com/archives/8998.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
