5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

/var/tmp・/tmpっていつ消えるの?

Posted at

勉強前イメージ

/ver/tmpは30日、/tmpは10日とか?
裏でcron走ってた記憶有るけど、正しく覚えてない

調査

そもそも/ver/tmp・/tmpって?

どちらも一時ファイルを置くテンポラリーのディレクトリ。
/ver/tmpは再起動しても消えないが、/tmpは消える

/ver/tmp・/tmpの違い

/ver/tmp

5.15.1. Purpose
The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp.
Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored
in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less
frequent interval than /tmp.
-------------------
5.15.1. 目的
var/tmp ディレクトリは、システムの再起動の間に保存される一時的なファイルやディレクトリを必要とするプログラムのために利用できるようになっています。そのため、/var/tmp に保存されているデータは、/tmp に保存されているデータよりも永続的です。
var/tmpにあるファイルやディレクトリは、システムの起動時に削除してはいけません。ただし、/var/tmp に保存されているデータは
の中の /var/tmp は通常、サイト固有の方法で削除されます。
tmpよりも頻繁に間隔を空けてください。

/tmp

3.17.1. Purpose
The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the
program.
-------------------
3.17.1. 目的
tmp ディレクトリは、一時的なファイルを必要とするプログラムで利用できるようにしなければなりません。
プログラムは、プログラムの呼び出しの間に /tmp 内のファイルやディレクトリが保存されていると仮定してはなりません。

設定情報

CentOS7では、
/var/tmp , /tmp のデータは systemdのデーモンで systemd-tmpfiles-clean.timer があり、こいつが消してるらしい
以下の設定ファイルに記載されている

cat /usr/lib/tmpfiles.d/tmp.conf
==========
...

# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d

...
==========

勉強後イメージ

どこでデータ削除されてるか知らなかった。
CentOS6,7でどこで削除されるかは違うらしい。
基本的には/var/tmpで置いてる。

参考

5
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?