7

CentOS-7中tmp目录的清理规则

 3 years ago
source link: http://www.eryajf.net/3142.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
CentOS-7中tmp目录的清理规则 |坐而言不如起而行! 二丫讲梵
> 术业专攻 > Linux基础 > 系统与优化 > CentOS-7中tmp目录的清理规则
本文预计阅读时间 3 分钟

因为目前业务当中遇到程序启动之后自动在/tmp目录下生成一个tomcat.1234546854的文件,有时候程序在上传文件的时候会读取一下这个目录,但是如果服务很久(超过十天)没发布过,那么这个目录可能就被自动清理了,然后导致服务报错。然后在网上看到了如下内容:

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

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

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

  1. /etc/tmpfiles.d/*.conf
  2. /run/tmpfiles.d/*.conf
  3. /usr/lib/tmpfiles.d/*.conf

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

  1. v /tmp 1777 root root 10d
  2. v /var/tmp 1777 root root 30d
  3. x /tmp/systemd-private-%b-*
  4. X /tmp/systemd-private-%b-*/tmp
  5. x /var/tmp/systemd-private-%b-*
  6. X /var/tmp/systemd-private-%b-*/tmp

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

  1. x /tmp/tomcat.*

weinxin

二丫讲梵 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明CentOS-7中tmp目录的清理规则

Recommend

  • 23

    From writing to /tmp to a root shell on Inteno IOPSYS CVE-2018-14533 Jul 21, 2018 In this blog p...

  • 10

    Table of Contents最近遇到磁盘占用 100% 的问题,发现 /tmp 目录下多出许多类似 my-app.jar-spring-boo-libs-xxx 的目录。这些目录是什么,如何避免磁盘爆了? 这些目录是什么? Spring boot 会将依赖的...

  • 10

    【重磅】圈钱千万的“庭美TMP”:敢维权,就弄了你!_区块链资讯_链向财经【重磅】圈钱千万的“庭美TMP”:敢维权,就弄了你!01-05 16:33标签币圈

  • 12
    • tmpout.sh 4 years ago
    • Cache

    tmp.0ut

    tmp.0ut ┌───────────────────────┐ ▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄ │ │ █ █ █ █ █...

  • 6

    论临时变量名 tmp 与代码的语感 谢益辉 / 2018-04-24 在审阅谭显英壮士的一个补丁时,我注意到一个在码农中极为常见的变量名,那就是万能的 tmp

  • 10
    • help.dreamhost.com 3 years ago
    • Cache

    /tmp directory overview

    /tmp directory overview Overview Web servers have a directory named /tmp used to store temporary files. Many programs use this /tmp directory for writing temporary data and general...

  • 6
    • computingforgeeks.com 3 years ago
    • Cache

    Mount /tmp on a separate partition in Linux

    Mount /tmp on a separate partition in LinuxBy default, /tmp directory is under / partition. In this guide, I’ll show you how you can create a separate partition for /tmp on LVM and mount it with some restrictions for security purposes....

  • 3

    Shopee平台不活跃商品清理规则更新 ...

  • 5

    linux Linux 临时目录 /tmp 与 /var/tmp 如果您已经使用 Linux 一段时间,那么您一定遇到过 /tmp 目录。您可能对此有所了解,但您可能认为它不会...

  • 3

    order:使用GPT-4自动清理文件目录 - 极道 order是一个方便的 CLI 工具,您可以使用它来利用 LLM 来组织您的文件和文件夹。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK