CentOS tmp目录自动清理问题

博客内容介绍了系统如何配置自动清理tmp目录的详细过程,包括配置文件/etc/tmpfiles.d/*.conf、/run/tmpfiles.d/*.conf和/usr/lib/tmpfiles.d/*.conf。重点关注了/usr/lib/tmpfiles.d/tmp.conf文件中的规则,如设置清理周期、排除特定目录以及保留私有临时目录等。这些配置确保了系统的临时文件管理,并防止磁盘空间被无用文件占用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目部署存储目录默认在tmp文件下  过一段时间会被系统自动清理

相关配置文件有三个

/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
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d

# 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
X /tmp/storage.*
X /tmp/data.*

# Remove top-level private temporary directories on each boot
R! /tmp/systemd-private-*
R! /var/tmp/systemd-private-*
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值