CentOS7的/tmp目录自动清理规则(转)
生活随笔
收集整理的這篇文章主要介紹了
CentOS7的/tmp目录自动清理规则(转)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
CentOS7的/tmp目錄自動清理規(guī)則
CentOS6以下系統(tǒng)(含)使用watchtmp + cron來實(shí)現(xiàn)定時(shí)清理臨時(shí)文件的效果,這點(diǎn)在CentOS7發(fā)生了變化,在CentOS7下,系統(tǒng)使用systemd管理易變與臨時(shí)文件,與之相關(guān)的系統(tǒng)服務(wù)有3個(gè):
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相關(guān)的配置文件也有3個(gè)地方:
/etc/tmpfiles.d/*.conf /run/tmpfiles.d/*.conf /usr/lib/tmpfiles.d/*.conf/tmp目錄的清理規(guī)則主要取決于/usr/lib/tmpfiles.d/tmp.conf文件的設(shè)定,默認(rèn)的配置內(nèi)容為:
# 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我們可以配置這個(gè)文件,比如你不想讓系統(tǒng)自動清理/tmp下以tomcat開頭的目錄,那么增加下面這條內(nèi)容到配置文件中即可:
x /tmp/tomcat.*轉(zhuǎn):https://blog.51cto.com/kusorz/2051877?utm_source=oschina-app
轉(zhuǎn)載于:https://www.cnblogs.com/ql211lin/p/10576524.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的CentOS7的/tmp目录自动清理规则(转)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery控制css的display(
- 下一篇: BZOJ4205卡牌配对——最大流+建图