[macOS General] Mac では /tmp は3日後に削除される

こちらを読んで Mac はどうなっているのかなとちょっと調べた memo.

[markdown]
> * [Linux – /tmpと/var/tmpの仁義無き戦い – Qiita](http://qiita.com/kuni-nakaji/items/f29be14be578b5a19d4b?utm_source=Qiita%E3%83%8B%E3%83%A5%E3%83%BC%E3%82%B9&utm_campaign=4e1d4472b5-Qiita_newsletter_99_9_4_2014&utm_medium=email&utm_term=0_e44feaa081-4e1d4472b5-32774809)

こちらを見つけました。

> * [osx – In Mac OS X, how often is /tmp deleted? – Super User](http://superuser.com/questions/187071/in-mac-os-x-how-often-is-tmp-deleted)

launchd がデイリーで `/usr/sbin/periodic` を実行している。
(起動時間はどうやって調べれば良いのだろうか?)
Mavericks には `/etc/defaults/periodic.conf` があって、確かに設定が書かれていました。

“`bash:/etc/defaults/periodic.conf
# 110.clean-tmps
daily_clean_tmps_enable=”YES” # Delete stuff daily
daily_clean_tmps_dirs=”/tmp” # Delete under here
daily_clean_tmps_days=”3″ # If not accessed for
daily_clean_tmps_ignore=”.X*-lock .X11-unix .ICE-unix .font-unix .XIM-unix”
daily_clean_tmps_ignore=”$daily_clean_tmps_ignore quota.user quota.group”
# Don’t delete these
daily_clean_tmps_verbose=”YES” # Mention files deleted
“`

3日間アクセスがなかったものは削除されるそう。
`/etc/periodic/daily/110.clean-tmps` をみたところ、`find` コマンドに `-atime` `-mtime` オプションをつけてごにょごにょして対象をピックアップしてました。

こんな形でオプションをつけられるのか。
modified が3日より古いファイル。

“`prettyprinted
% find ~/Downloads -name *.png -mtime +3
/Users/****/Downloads/AppCleaner.png
“`

/var/tmp をどうしているかはよくわからない。

## 補遺

> * [Running Mac OS X Maintenance Scripts](http://www.thexlab.com/faqs/maintscripts.html)
> * [launchdをcronの代わりに使うための簡易メモ – Mekajikiの日記](http://d.hatena.ne.jp/swordfishii/20110404/1301930165)
> * [Tmpディレクトリの活用法について改めて考える – RickyNews](http://www.rickynews.com/blog/2014/09/20/importance-of-temporary-directories/)
> * [/tmp と /var/tmp の違い – しょぼんメモリ (´・ω・`)](http://shobon.hatenablog.com/entry/2014/07/30/223550)
[/markdown]