/tmp目录文件重启后自动删除现在知道有ubuntu和solaris系统 经常会把临时性的log或抓包等文件放在/tmp目录下,重启后发现文件都丢失了。查下资料发现,可以通过设置解决这个问题。 在/etc/default/目录下有个rcS文件,文件内容如下: # # /etc/default/rcS # # Default settings for the scripts in /etc/rcS.d/ # # For information about these variables see the rcS(5) manual page. # # This file belongs to the "initscripts" package. TMPTIME=0 SULOGIN=no DELAYLOGIN=no UTC=yes VERBOSE=no FSCKFIX=no RAMRUN=no RAMLOCK=no 红色字体TMPTIME=0 值为0表示重启后删除文件,值为-1就不会自动删除文件,职位正整数表示/tmp目录下文件保留时间。 关于linux系统/tmp下文件自动删除的问题 /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 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 我们可以配置这个文件,比如你不想让系统自动清理/tmp下以tomcat开头的目录,那么增加下面这条内容到配置文件中即可: x /tmp/tomcat.* |
Copyright © 2002-2024 Iszw.net All Rights Reserved. 川公网安备 51010702002244号
蜀ICP备2020035322号-1 本站已开启 IPv6 访问