1. 程式人生 > 其它 >CentOS7 /tmp目錄自動清理

CentOS7 /tmp目錄自動清理

CentOS7 /tmp目錄自動清理

林中靜月下仙

於 2019-05-09 13:51:34 釋出

3506
收藏 4
分類專欄: linux 文章標籤: linux tmp
版權

linux
專欄收錄該內容
27 篇文章3 訂閱
訂閱專欄
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 7d
v /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
如你不想讓系統自動清理/tmp下以tomcat開頭的目錄,那麼增加下面這條內容到配置檔案中即可:

x /tmp/tomcat.*

————————————————
版權宣告:本文為CSDN博主「林中靜月下仙」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處連結及本宣告。
原文連結:https://blog.csdn.net/qq_21137441/article/details/90031390