CentOS7的/tmp目录自动清理规则

CentOS6以下系统(含)使用watchtmp + cron来实现定时清理临时文件的效果,这点在CentOS7发生了变化,在CentOS7下,系统使用systemd管理易变与临时文件,与之相关的系统服务有3个:

systemd-tmpfiles-setup.service  :Create Volatile Files and Directories
systemd-tmpfiles-setup-dev.service:Create static device nodes in /dev
systemd-tmpfiles-clean.service :Cleanup of Temporary Directories

相关的配置文件也有3个地方:

/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf

/tmp目录的清理规则主要取决于/usr/lib/tmpfiles.d/tmp.conf文件的设定,默认的配置内容为:

#  This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version. # See tmpfiles.d(5) for details # Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d # 清理/tmp下10天前的目录和文件
v /var/tmp 1777 root root 30d # 清理/var/tmp下30天前的目录和文件 # Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

我们可以配置这个文件,比如你不想让系统自动清理/tmp下以tomcat开头的目录,那么增加下面这条内容到配置文件中即可:

x /tmp/tomcat.*

转:https://blog.51cto.com/kusorz/2051877?utm_source=oschina-app

最新文章

  1. 让easyui 的alert 消息框中的确定按钮支持空格键
  2. java加法流程图
  3. PHP从数据库导出EXCEL文件
  4. JS之数组
  5. http://blog.csdn.net/lvyuanj/article/details/51235135
  6. PHP连接局域网MYSQL数据库的简单实例
  7. POJ 1321 棋盘问题 DFS搜索
  8. Java随机数生产算法
  9. C#中使用ServiceStack.Redis
  10. Django ORM模型的一点体会
  11. 573. Squirrel Simulation
  12. C#实现基于ffmepg加虹软的人脸识别
  13. [Java第一个游戏]JFrame文本框下贪吃蛇
  14. 数据结构之队列c代码实现
  15. 六、OpenStack—neutron组件介绍与安装
  16. JDBC中常用的接口
  17. js 立即执行函数
  18. CommonJS、AMD、CMD和ES6模块化区别
  19. java Enum 类型互转
  20. excel输入数字变成特殊符号问题

热门文章

  1. CentOS 7下安装配置FTP
  2. CSS定位与布局:普通流
  3. MySQL错误:Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL easonjim
  4. php cli模式下调试
  5. Linux ClientDataSet libmidas.so.2
  6. php从数据库选取记录形成列表(首页调用)
  7. Android 使用意图播放本地视频
  8. 使用struts2完成ckeditor和图片上传
  9. typedef 与 define 的区别
  10. Oracle中Hint深入理解(原创)