{"id":1454,"date":"2023-03-23T22:25:17","date_gmt":"2023-03-23T14:25:17","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1454"},"modified":"2023-04-28T20:43:17","modified_gmt":"2023-04-28T12:43:17","slug":"centos-7-tmp-directory-automatic-cleaning-rule","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/23\/centos-7-tmp-directory-automatic-cleaning-rule\/","title":{"rendered":"CentOS7\u7684\/tmp\u76ee\u5f55\u81ea\u52a8\u6e05\u7406\u89c4\u5219"},"content":{"rendered":"<p>CentOS6\u4ee5\u4e0b\u7cfb\u7edf\uff08\u542b\uff09\u4f7f\u7528<code>watchtmp + cron<\/code>\u6765\u5b9e\u73b0\u5b9a\u65f6\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u7684\u6548\u679c\uff0c\u8fd9\u70b9\u5728CentOS7\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5728CentOS7\u4e0b\uff0c\u7cfb\u7edf\u4f7f\u7528<code>systemd<\/code>\u7ba1\u7406\u6613\u53d8\u4e0e\u4e34\u65f6\u6587\u4ef6\uff0c\u4e0e\u4e4b\u76f8\u5173\u7684\u7cfb\u7edf\u670d\u52a1\u67093\u4e2a\uff1a<\/p>\n<pre><code>systemd-tmpfiles-setup.service  \uff1aCreate Volatile Files and Directories\nsystemd-tmpfiles-setup-dev.service\uff1aCreate static device nodes in \/dev\nsystemd-tmpfiles-clean.service \uff1aCleanup of Temporary Directories<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u76f8\u5173\u7684\u914d\u7f6e\u6587\u4ef6\u4e5f\u67093\u4e2a\u5730\u65b9\uff1a<\/p>\n<pre><code>\/etc\/tmpfiles.d\/*.conf\n\/run\/tmpfiles.d\/*.conf\n\/usr\/lib\/tmpfiles.d\/*.conf<\/code><\/pre>\n<p><code>\/tmp<\/code>\u76ee\u5f55\u7684\u6e05\u7406\u89c4\u5219\u4e3b\u8981\u53d6\u51b3\u4e8e<code>\/usr\/lib\/tmpfiles.d\/tmp.conf<\/code>\u6587\u4ef6\u7684\u8bbe\u5b9a\uff0c\u9ed8\u8ba4\u7684\u914d\u7f6e\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre><code>#  This file is part of systemd.\n#\n#  systemd is free software; you can redistribute it and\/or modify it\n#  under the terms of the GNU Lesser General Public License as published by\n#  the Free Software Foundation; either version 2.1 of the License, or\n#  (at your option) any later version.\n\n# See tmpfiles.d(5) for details\n\n# Clear tmp directories separately, to make them easier to override\nv \/tmp 1777 root root 10d           #   \u6e05\u7406\/tmp\u4e0b10\u5929\u524d\u7684\u76ee\u5f55\u548c\u6587\u4ef6\nv \/var\/tmp 1777 root root 30d       #   \u6e05\u7406\/var\/tmp\u4e0b30\u5929\u524d\u7684\u76ee\u5f55\u548c\u6587\u4ef6\n\n# Exclude namespace mountpoints created with PrivateTmp=yes\nx \/tmp\/systemd-private-%b-*\nX \/tmp\/systemd-private-%b-*\/tmp\nx \/var\/tmp\/systemd-private-%b-*\nX \/var\/tmp\/systemd-private-%b-*\/tmp<\/code><\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u914d\u7f6e\u8fd9\u4e2a\u6587\u4ef6\uff0c\u6bd4\u5982\u4e0d\u60f3\u8ba9\u7cfb\u7edf\u81ea\u52a8\u6e05\u7406<code>\/tmp<\/code>\u4e0b\u4ee5tomcat\u5f00\u5934\u7684\u76ee\u5f55\uff0c\u90a3\u4e48\u589e\u52a0\u4e0b\u9762\u8fd9\u6761\u5185\u5bb9\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u5373\u53ef\uff1a<\/p>\n<pre><code>x \/tmp\/tomcat.*<\/code><\/pre>\n<p>\u66f4\u591a\u914d\u7f6e\u5185\u5bb9\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/www.jinbuguo.com\/systemd\/tmpfiles.d.html\" title=\"tmpfiles.d \u4e2d\u6587\u624b\u518c\">tmpfiles.d \u4e2d\u6587\u624b\u518c<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS6\u4ee5\u4e0b\u7cfb\u7edf\uff08\u542b\uff09\u4f7f\u7528watchtmp + cron\u6765\u5b9e\u73b0\u5b9a\u65f6\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u7684\u6548\u679c\uff0c\u8fd9\u70b9\u5728CentOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1454","post","type-post","status-publish","format-standard","hentry","category-devops-base"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1454"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1454\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}