관리 메뉴

Sysops Notepad

[LINUX] /tmp 과 /var/tmp 차이점 본문

업무/sys

[LINUX] /tmp 과 /var/tmp 차이점

sysops 2022. 4. 12. 10:18

CentOS6까지는 /etc/cron.daily/tmpwatch 라는 스크립트가 위 디렉터리에 있는 파일들을 삭제하는데

CentOS7과 Centos8은 systemd-tmpfiles가 /usr/lib/tmpfiles.d/tmp.conf 파일을 참고하여 돟작합니다.

/tmp : 재부팅시 파일 삭제. 재부팅을 하지 않아도 정기적으로 10일마다 삭제
/var/tmp : 재부팅 파일 삭제하지 않으나 정기적으로 30일마다 삭제

[root@test-01 /]# cat /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
v /var/tmp 1777 root root 30d

# 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

참고로 systemd-tmpfiles-clean.service 서비스에 의해서 파일이 삭제됩니다.

Comments