偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

詳解Centos 7和Centos 6系統(tǒng)的/tmp目錄自動(dòng)清理規(guī)則及區(qū)別

運(yùn)維 系統(tǒng)運(yùn)維 Linux
分享最近應(yīng)用碰到的一個(gè)奇怪bug,一開始以為是代碼上的問題,找了一段時(shí)間發(fā)現(xiàn)居然是因?yàn)橄到y(tǒng)的一個(gè)自動(dòng)清理規(guī)則導(dǎo)致,下面一起來看看吧~

概述

分享最近應(yīng)用碰到的一個(gè)奇怪bug,一開始以為是代碼上的問題,找了一段時(shí)間發(fā)現(xiàn)居然是因?yàn)橄到y(tǒng)的一個(gè)自動(dòng)清理規(guī)則導(dǎo)致,下面一起來看看吧~

一、應(yīng)用報(bào)錯(cuò): 

  1. logwire.core.exceptions.GeneralUnhandledException: 服務(wù)端未處理異常  
  2. ...  
  3. Caused by: org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is  
  4. java.io.IOException: The temporary upload location [/tmp/tomcat.5454715517323162300.8031/work/Tomcat/localhost/ROOT] is not valid  
  5. ....  
  6. Caused by: java.io.IOException: The temporary upload location [/tmp/tomcat.5454715517323162300.8031/work/Tomcat/localhost/ROOT] is not valid 

報(bào)錯(cuò)截圖:

二、思路

CentOS 7 系統(tǒng)有一個(gè)默認(rèn)定時(shí)器會(huì)每隔 1 天執(zhí)行一次臨時(shí)目錄清理操作,把 /tmp 目錄下所有超過 10 天沒有任何變動(dòng)的子目錄全部刪除。

若某個(gè) Logwire 系統(tǒng)的用戶操作不太活躍,則 tomcat 運(yùn)行臨時(shí)目錄(形如: /tmp/tomcat.xxx)會(huì)被刪除。這時(shí)候如果有用戶試圖上傳文件,則服務(wù)端會(huì)報(bào)錯(cuò):

The temporary upload location [/tmp/tomcat.5454715517323162300.8031/work/Tomcat/localhost/ROOT] is not valid

三、處理過程

在 /usr/lib/tmpfiles.d/tmp.conf 文件中增加配置項(xiàng): 

  1. x /tmp/tomcat* 

以上配置表示在清理臨時(shí)目錄時(shí)忽略所有以 /tmp/tomcat 開頭的目錄和文件

四、CentOS系統(tǒng)的/tmp目錄自動(dòng)清理規(guī)則

1、CentOS 7

CentOS7下,系統(tǒng)使用systemd管理易變與臨時(shí)文件,與之相關(guān)的系統(tǒng)服務(wù)有3個(gè): 

  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 

相關(guān)的配置文件也有3個(gè)地方: 

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

/tmp目錄的清理規(guī)則主要取決于/usr/lib/tmpfiles.d/tmp.conf文件的設(shè)定,默認(rèn)配置有: 

  1. # This file is part of systemd.  
  2.  
  3. # systemd is free software; you can redistribute it and/or modify it  
  4. # under the terms of the GNU Lesser General Public License as published by  
  5. # the Free Software Foundation; either version 2.1 of the License, or  
  6. # (at your option) any later version.  
  7. # See tmpfiles.d(5) for details  
  8. # Clear tmp directories separately, to make them easier to override  
  9. v /tmp 1777 root root 10d # 清理/tmp下10天前的目錄和文件  
  10. v /var/tmp 1777 root root 30d # 清理/var/tmp下30天前的目錄和文件  
  11. # Exclude namespace mountpoints created with PrivateTmp=yes  
  12. x /tmp/systemd-private-%b-*  
  13. X /tmp/systemd-private-%b-*/tmp  
  14. x /var/tmp/systemd-private-%b-*  
  15. X /var/tmp/systemd-private-%b-*/tmp 

也就是CentOS 7 系統(tǒng)有一個(gè)默認(rèn)定時(shí)器會(huì)每隔 1 天執(zhí)行一次臨時(shí)目錄清理操作,把 /tmp 目錄下所有超過 10 天沒有任何變動(dòng)的子目錄全部刪除。

可以配置這個(gè)文件,比如你不想讓系統(tǒng)自動(dòng)清理/tmp下以tomcat開頭的目錄,那么增加下面這條內(nèi)容到配置文件中即可: 

  1. x /tmp/tomcat.* 

2、CentOS 6

CentOS6以下系統(tǒng)(含)使用watchtmp + cron來實(shí)現(xiàn)定時(shí)清理臨時(shí)文件的效果,該目錄下的腳本每天執(zhí)行一次。

如果要修改的話,可以修改此 tmpwatch 腳本(用 root 用戶修改或其他用戶 sudo 修改):

找到類似該語句: 

  1. /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \  
  2. -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \  
  3. -X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \  
  4. 10d /tmp 

為該語句添加 -X '/tmp/tomcat*' 參數(shù),以便在清除時(shí)忽略所有以 /tmp/tomcat 開頭的目錄和文件: 

  1. /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \  
  2. -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \  
  3. -X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \ 
  4. -X '/tmp/tomcat*' \  
  5. 10d /tmp 

覺得有用的朋友多幫忙轉(zhuǎn)發(fā)哦!后面會(huì)分享更多devops和DBA方面的內(nèi)容,感興趣的朋友可以關(guān)注下~ 

 

責(zé)任編輯:龐桂玉 來源: 今日頭條
相關(guān)推薦

2016-08-12 14:37:52

Linux tmpRedhattmpwatch

2014-08-07 10:07:13

RHELCentOS

2012-08-08 10:10:30

CentOS 6操作系統(tǒng)

2021-08-11 06:16:27

CentOS 7 MongodbC++

2023-06-01 08:15:04

CentOS紅帽

2022-07-26 15:22:46

CentOS 7腳本Linux

2010-03-31 15:08:28

CentOS系統(tǒng)

2010-03-31 15:24:15

CentOS系統(tǒng)

2010-01-14 14:32:07

CentOS ligh

2013-05-03 10:21:53

CentOSRedHat Linu

2020-06-09 07:00:00

RHELCentOSFedora

2010-03-23 08:46:07

Windows 7系統(tǒng)優(yōu)化

2024-03-01 20:28:54

CentOS 7文件操作search

2014-08-06 16:32:50

2013-11-11 09:34:51

超6類7類網(wǎng)線

2017-02-27 11:06:59

RHEL7CentOS7密碼

2012-07-11 17:09:34

Windows 7CentOS

2024-04-10 13:50:41

CentOSUbuntu操作系統(tǒng)

2023-05-20 17:48:39

Linux/tmp/var/tmp

2013-04-15 15:07:43

清理日志Linux系統(tǒng)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)