关于Linux系统清理/tmp/文件夹的清理时间等

关于Linux系统清理/tmp/文件夹的清理时间等

我们知道,在Linux系统中/tmp文件夹里面的文件会被清空,至于多长时间被清空,如何清空的,可能大家知识的就不多了,所以,今天我们就来剖析一个这两个问题。

在RHEL\CentOS\Fedora\系统中(本次实验是在RHEL6中进行的)
先来看看tmpwatch这个命令,他的作用就是删除一段时间内不使用的文件(removes files which haven’t been accessed for a period of time)。具体的用法就不多说了,有兴趣的自行研究。我们主要看看和这个命令相关的计划任务文件。
他就是/etc/cron.daily/tmpwatch,我们可以看一下这个文件里面的内容

#! /bin/s

flags=-umc
 /usr/sbin/tmpwatch “$flags” -x /tmp/.X11-unix -x /tmp/.XIM-unix \
 -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
 -X ‘/tmp/hsperfdata_*’ 10d /tmp
 /usr/sbin/tmpwatch “$flags” 30d /var/tmp
 for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
 if [ -d “$d” ]; then
 /usr/sbin/tmpwatch “$flags” -f 30d “$d”
 fi
 done

这个脚本大家仔细分析一下就明白了,第一行相当于一个标记(参数),第二行就是针对/tmp目录里面排除的目录,第三行,这是对这个/tmp目录的清理,下面的是针对其他目录的清理,就不说了。

我们就来看/usr/sbin/tmpwatch “$flags” 30d /var/tmp这一行,关键的是这个30d,就是30天的意思,这个就决定了30天清理/tmp下不访问的文件。如果说,你想一天一清理的话,就把这个30d改成1d。这个你懂的……哈哈!

但有个问题需要注意,如果你设置更短的时间来清理的话,比如说是30分钟、10秒等等,你可以在这个文件中设置,但你会发现重新电脑,他不清理/tmp文件夹里面的内容,这是为什么呢?这就是tmpwatch他所在的位置决定的,他的上层目录是/etc/cron.daily/,而这个目录是第天执行一次计划任务,所以说,你设置了比一天更短的时间,他就不起作用了。这下明白了吧。
所以结论是:在RHEL6中,系统自动清理/tmp文件夹的默认时限是30天

在Debian\Ubuntu系统中(Ubuntu10.10为实验环境)
在Ubuntu系统中,在/tmp文件夹里面的内容,每次开机都会被清空,如果不想让他自动清理的话,只需要更改rcS文件中的TMPTIME的值。
我们看如何来修改 sudo vi /etc/default/rcS
把 TMPTIME=0

修改成 TMPTIME=-1或者是无限大

改成这样的话,系统在重新启动的时候就不会清理你的/tmp目录了。
依些类推,如果说要限制多少时间来更改的话,就可以改成相应的数字(本人没有测试,我是这么理解的)

所以结论是:在Ubuntu中,系统自动清理/tmp文件夹的时限默认每次启动

本文章固定链接:www.rakbuluo.com/p62

原文链接:,转发请注明来源!

发表评论

  • 87 Responses to “关于Linux系统清理/tmp/文件夹的清理时间等”
    • Kndnboop

      what drugs should not be taken with viagra? <a href="http://viagratx.com/ ">canadian viagra</a> walgreens viagra substitute

      回复
    • drug store xezjai

      canada pharmacies online <a href="http://edpharmacystore.com/">article source</a> indian pharma
      <a href=http://edpharmacystore.com/>article</a>

      回复
    • FqbbAniny

      quick cash loans south carolina <a href="http://ascashapply.com/ ">fast business cash loans</a> how to get easy cash in payday 2

      回复
    • Jbnvblafe

      loaning money to family tax implications <a href="http://samcash21.com/ ">new payday loan laws in texas</a> ace payday loan promo codes

      回复
    • Nbnhprest

      200mg sildenafil soft gel capsule <a href="http://vigedon.com/ ">uk viagra buy </a> real viagra online usa

      回复
    • CharlesHob

      tinder online , tinder app
      [url="http://tinderdatingsiteus.com/?"]tinder login[/url]

      回复
    • JbbnAniny

      cialis spedizione ups <a href="http://ljcialishe.com/ ">cialis al femminile</a> diferença cialis x viagra

      回复
    • viagra online prnepg

      pharmacy rx one 60 mg cialis <a href="http://edpharmacystore.com/">this</a> cvs pharmacy
      <a href=http://edpharmacystore.com/>learn more</a>

      回复
    • Fbsgprest

      voucher cialis index <a href="https://llecialisjaw.com/ ">http://llecialisjaw.com/ </a> cialis buy onilne

      回复
    • KbbfIdovE

      where can i get viagra overnight <a href="http://kloviagrli.com/ ">viagraaustralia </a> viagra gel

      回复
    • Abcfbopinnots

      5 viagra pills <a href="http://viagriyvik.com/ ">http://viagriyvik.com/ </a> viagra canada

      回复
    • purchase viagra jpyimt

      no prescription pharmacy <a href="http://edpharmacystore.com/">my review here</a> canadian cialis online pharmacy
      <a href=http://edpharmacystore.com/>browse around this site</a>

      回复
    • LabxAniny

      diferenças levitra viagra cialis <a href="https://jecialisbn.com/ ">cialis preço mais barato</a> cialis kullananlar forum

      回复
    • Kvaxboop

      various types of loans and advances <a href="http://rirocash.com/ ">ready cash payday loans sikeston mo</a> payday loans no paperwork required

      回复
    • Jbnbblafe

      canadian online pharmacy reviews <a href="http://online21rxon.com/ ">anti viral</a> buy prescription drugs from canada

      回复
    • FqhhAniny

      canadian rx pharmacy online <a href="http://happyrxpharmacy21.com/ ">canadian pharmacy viagra</a> canadian family pharmacy

      回复
    • JbbvAniny

      drug costs <a href="http://canadianpharmnorx.com/ ">order prescriptions online without doctor</a> general health

      回复
    • Nncsprest

      best viagra price <a href="http://lightvigra.com/ ">free viagra online without prescription</a> viagra cheap generic cialis

      回复
    • KuikIdovE

      viagra free sample <a href="http://viagerkr.com/ ">order viagra online</a> viagra patent ending

      回复
    • Fvfcprest

      viagra free delivery uk <a href="http://hopeviagrin.com/ ">viagra for sale australia</a> compare generic viagra prices

      回复
    • Aqcfbopinnots

      cialisis online <a href="http://cialisvja.com/ ">generic cialis (tadalafil) 20mg 30</a> viagra levitra cialis which works better?

      回复
    • AhkdAniny

      Cialis <a href="http://storerxpharmcanada.com/ ">canada drugs online</a> pharmacie canadienne

      回复
    • LbsxAniny

      canadian pharmacies top best <a href="https://ssviagriia.com/ ">canadian viagra buy via paypal</a> anti viral

      回复
    • Kbcxboop

      doctor prescription <a href="http://xuypharmacyonline.com/">board of pharmacy</a> canadadrugsonline

      回复
    • generic viagra india evqvxj

      cialis for daily use canada <a href=http://www.canada1drugstore.com/tadalafil/>viagra without a prescription</a> canadian pharcharmy
      <a href="http://www.canada1drugstore.com/tadalafil/">online pharmacy viagra</a> canadian online pharmacy cialis

      回复
    • CharlesHob

      tinder online , what is tinder
      <a href=http://tinderdatingsiteus.com/?>browse tinder for free </a>

      回复
    • JdbxAniny

      viagra sources <a href="http://llviabest.com/#">where to buy viagra in canada</a> generic viagra, 100mg http://llviabest.com/ - viagra for sale in south afriaca ’

      回复
    • CharlesHob

      tindr , tinder dating app
      <a href=http://tinderdatingsiteus.com/?>tinder website </a>

      回复
    • FmnfAniny

      buy cialis cheap <a href="https://impotencecdny.com/info/history.php">cialis 20mg</a> cialis oline https://impotencecdny.com/info/history.php - cialis strips ’

      回复
    • Jnscblafe

      what is viagra black <a href="http://erectilejyzd.com/index.php?called=terms">viagra overnight shipping</a> viagra sales http://erectilejyzd.com/index.php?called=terms - cheap viagra ’

      回复
    • cialis-canada fxhuqm

      canada rx pharmacy <a href="https://sportbookmark.stream/story.php?title=one-of-the-most-unique-tips-for-losing-more-weight-4#discuss">best viagra</a> viagra overnight delivery <a href=http://wert-tools.ru/user/AndersenVad6/>free samples of viagra</a> alcohol and viagra
      cialis online in canada <a href="http://zohil.net/index.php?qa=user&qa_1=duushorowitz8">order cheap viagra</a> viagra for sale online <a href=https://manchesterclopedia.win/wiki/Overview_On_How_To_Overcome_Diabetes_Easily>canadadrugstoresonline.com</a> canadian rx pharmacy
      generic cialis canada <a href="https://getpocket.com/@begumkvist6">canada rx</a> viagra generic canada <a href=http://www.castagneto.eu/index.php?option=com_k2&view=itemlist&task=user&id=1786028>female viagra</a> canada pharmacy cialis
      costco pharmacy

      回复
    • Kbbgboop

      viagra usa <a href="http://erectilejyzd.com/#">canadian pharmacies-24h</a> buy viagra pay pal http://erectilejyzd.com/ - online pharmacy usa ’

      回复
    • AhmdAniny

      cheap cialis prices <a href="https://impotencecdny.com/">meds online</a> viagra vs cialis forum https://impotencecdny.com/ - shoppers drug mart pharmacy ’

      回复
    • viagra wikipedia zcqseg

      international drug mart <a href=http://www.canada1drugstore.com/tadalafil/>prescription medication canada</a> india pharmacy viagra
      <a href="http://www.canada1drugstore.com/tadalafil/">buy viagra online cheap</a> medicine from canada

      回复
    • Fbgprest

      buying viagra sending to australia <a href="https://canadianpharmacy-usx.com/organic.htm">indo viagral</a> buy viagra online with paypal https://canadianpharmacy-usx.com/organic.htm - the most powerful viagra in the world ’

      回复
    • Nmilprest

      viagraprise <a href="http://xz-pharmacyonline.com/en/career-opportunities.html">low price viagra</a> viagra mg dose http://xz-pharmacyonline.com/en/career-opportunities.html - generic viagra for sale online ’

      回复
    • LbgAniny

      viagra paypal uk <a href="http://genqpviag.com/#">viagra 100mg</a> toronto viagra http://genqpviag.com/ - buy viagra on line ’

      回复
    • FmfvAniny

      supreme suppliers cialis <a href="http://sjcialis.com/#">200 mg cialis</a> buy cialis online canada http://sjcialis.com/ - viagra cialis on line parmacy ’

      回复
    • Tinder dating site

      tinder login, tinder dating app
      <a href=http://tinderdatingsiteus.com/?>tinder online </a>

      回复
    • Jnhblafe

      cheapest brand cialis 20mg <a href="http://loncialis.com/#">cialis no prescription overnight</a> cialis free trial offer http://loncialis.com/ - buy generic cialis generic cialis ’

      回复
    • Kbbtboop

      where can i buy cialis in canada <a href="https://xz-pharmacyonline.com/#">Sinequan</a> cialis super active https://xz-pharmacyonline.com - Prasugrel ’

      回复
    • Tinder dating site

      browse tinder for free , tider

      回复
    • how much is viagra iqypbz

      canada.viagra <a href=http://www.canada1drugstore.com/tadalafil/>price of cialis</a> cialis low price
      <a href="http://www.canada1drugstore.com/tadalafil/">order cialis online canada</a> ordering viagra online without prescription

      回复
    • AhmdAniny

      pictures of penis on cialis <a href="http://cialmenshoprx.com/#">cialis vs viagra germany</a> cialisi http://cialmenshoprx.com/ - no rx cialis ’

      回复
    • Fbdhprest

      cheapest generic cialis <a href="http://21cialismen.com/#">cialis generic 20 mg 30 pills</a> cialis in ireland http://21cialismen.com/ - generic cialis for sale ’

      回复
    • JbdcAniny

      discount viagra online <a href="http://llviabest.com/#">price for viagra</a> viagra online with american express http://llviabest.com/ - viagra austrailia buy ’

      回复
    • Nlbxprest

      cialis without prescription <a href="http://cialijomen.com/#">lowest price generic cialis</a> online cialis generic http://cialijomen.com/ - viagra levitra cialis offers ’

      回复
    • LcxAniny

      cvs viagra <a href="http://genqpviag.com/#">usa viagra</a> 5 viagra pills http://genqpviag.com/ - paypal viagra ’

      回复
    • FsbxAniny

      best place to buy viagra in sydney <a href="http://genericrxxx.com/#">viagra online from india</a> viagra canada paypal payment http://genericrxxx.com/ - quick tabs viagra ’

      回复
    • Jvcbxblafe

      cialis 80mg <a href="http://phrcialiled.com/#">viagra cialis comparison</a> cialis online canada ripoff http://phrcialiled.com/ - cialis 10mg pills ’

      回复
    • Kbctboop

      cialis egypt <a href="http://mycialedst.com/#">cialis with dapoxetine 80mg</a> cialis online doctor http://mycialedst.com/ - cheapest generic cialis ’

      回复
    • AqbvAniny

      overnight shipping on viagra <a href="http://acialaarx.com/#">viagra and dapoxetine with</a> buy sildenafil viagra http://acialaarx.com/ - cheapest place to buy viagra ’

      回复
    • Fgnhprest

      professional viagra cialis <a href="http://ltdviagragogo.com/#">viagra online</a> cipla viagra canada viagra online cheap <a href="http://hdgenericviagraxk.com/#">how to make viagra</a> superforce viagra viagra jelly for women <a href="http://buygenericviarga.com/#">generic. viagra</a> generic viagra price buy viagra on line <a href="http://buyhdpillvia.com/#">viagra side effects</a> viagra buy online paypal overnight me viagra <a href="http://genericviagrix.com/#">soft viagra</a> generic viagra for sale online

      回复
    • Nlbxprest

      viagra in toronto <a href="http://viashoprx.com/#">viagra truly overnight delivery usa</a> 50mg viagra overnightpharmacy4u brand viagra <a href="http://xviagarrx.com/#">viagra without ed</a> pfizer viagra australia viagra fro sale <a href="http://viagraviagria.com/#">viagra ireland paypal</a> walgreen viagra cost per pill viagra jelly sachet <a href="http://asgenviagria.com/#">viagra pillsm</a> 100mg viagra viagra, canada <a href="http://viagengen.com/#">buy viagra paypal</a> actual prescription cost of viagra

      回复
    • Jvcxblafe

      viagrafreesamples <a href="http://fmedrx.com/#">viagra australia paypal</a> viagra melbourne buy pink viagra online <a href="http://edabcrx.com/#">pfizer viagra</a> herbal viagra gnc where to buy viagra in australia <a href="http://abcrxmed.com/#">where to get viagra samples</a> viagra online stores mastercard that accept viagra top of the line <a href="http://cialedrx.com/#">viagra hong kong</a> professional strenght viagra buy viagra with dapoxetine <a href="http://hitrxmenvia.com/#">viagra in canada</a> viagra in australia chemist

      回复
    • Klioboop

      viagra on line australia <a href="http://bestviagrx.com/#">generic viagra soft tabs</a> australia viagra which is better viagra cialis or levitra <a href="http://viarxhd.com/#">viagra minn</a> viagraonlineaustralia free samples viagra genaric <a href="http://viagetpill.com/#">viagra in australia chemist</a> best viagra alternatives brand viagra 100mg online pfizer <a href="http://pillexrx.com/#">buy viagra 100 mg online</a> viagra australie what is super viagra <a href="http://usggrxmed.com/#">ordering viagra online is it legal</a> viagra for sale in usa with no prescription

      回复
    • FnrhAniny

      buy viagra online express shipping <a href="https://genqpviag.com/#">dizzy right after viagra</a> cheapest pharmacy gold coast viagra

      回复
    • Jgscblafe

      do my geometry <a href="https://thesisbyd.com/#">writing a satire essay</a> my last day at college essay quotations

      回复
    • FsfAniny

      cheap custom research papers cheap essay writing <a href="https://essayhelpbgs.com/#">college essay entrance</a> essay 26

      回复
    • college essay ideas help

      Help writing essays <a href="https://essayhelpbgs.com/">https://essayhelpbgs.com/</a> help
      writing essays for college

      回复
    • FtghAniny

      parents writing college essays <a href="https://thesiswritinghelpsjj.com/#">help me do my math homework</a> white paper writer

      回复
    • FnsbAniny

      college admission essay writing service <a href="https://customessaywriterbyz.com/#">cause and effect essay</a> exam essay writing

      回复
    • buy custom essays

      Buy an essay online cheap <a href="https://buyessayhelpbtg.com/">buyessayhelpbtg.com</a> buy an essay online cheap

      回复
    • FnrdAniny

      cipla viagra review <a href="https://llviabest.com/#">365 pills viagra</a> does walmart sell viagra?

      回复
    • Dvscprest

      trusted essay writing service <a href="https://dissertationhelpvfh.com/#">university personal statement</a> do my research paper cheap

      回复
    • FqfAniny

      research paper basics <a href="https://essaywritingservicesjy.com/#">fake essay writing website</a> college essays that stand out

      回复
    • Fgsprest

      writing comparison and contrast essays <a href="https://writemypaperbuyhrd.com/#">pay to write a paper</a> persuation essay

      回复
    • Kwgdboop

      college essays about dance <a href="https://researchpaperssfk.com/#">essay writing on teachers</a> executive resume writing services

      回复
    • FbsbAniny

      what happens if you take a whole bottle of viagra <a href="https://genericrxxx.com/#">viagra levitra e cialis qual o melhor</a> viagra for sale in los angeles

      回复
    • Jsweblafe

      viagra 100mg cost in usa <a href="https://mygoviagar.com/#">where can i get viagra in canada</a> cheap viagra online without prescription

      回复
    • FmsgAniny

      viagra song good morning lyrics <a href="https://siviagmen.com/#">viagra from india online</a> kann die wirkung von viagra nachlassen

      回复
    • Dbsfprest

      purchase female viagra online <a href="https://lightvigra.com/#">sildenafil cheapest price</a> viagra pill 100mg

      回复
    • Carlosfat

      mswyytzid cialis patent expiration date <a href=http://paukpasyans.ru/user/HvidbergCooper63/>cialis no prescription online</a> cialis online with prescription buy viagra an cialis online <a href="http://megazvezda.info/user/MendozaDaniel78/">canadian drugs</a>
      best cialis prices <a href=https://www.diigo.com/profile/haganholder3>discount cialis</a> ed pills without a prescription walmart cialis price <a href="http://bbs.rwx168.com/home.php?mod=space&uid=864171">cialis cost comparison</a>

      回复
    • Fdbvprest

      viagra singapore <a href="https://hopeviagrin.com/#">sildenafil prescription discount</a> 75 mg sildenafil

      回复
    • Kbrgboop

      viagra china <a href="https://miraclevigra.com/#">buy sildenafil online paypal</a> uk viagra prices

      回复
    • FhsbAniny

      come riconoscere chi usa viagra <a href="https://buybuyviamen.com/#">https://buybuyviamen.com</a> is cipla viagra good

      回复
    • Jivhblafe

      internetapotheke holland viagra <a href="https://purevigra.com/#">viagra pharmacie casablanca</a> online viagra usa

      回复
    • FbsgAniny

      viagra in duitsland <a href="https://buybuyviamen.com/#">levitra viagra oder cialis</a> viagra use dogs

      回复
    • Devkprest

      viagra online <a href="https://paradiseviagira.com/#">indian viagra reviews</a> viagra australia

      回复
    • Frbhprest

      buying egypt viagra <a href="https://paradiseviagira.com/#">https://paradiseviagira.com/</a> buying viagra sydney

      回复
    • Kmrfboop

      el viagra es recetado <a href="https://purevigra.com/#">https://purevigra.com</a> combinaison viagra cialis

      回复
    • KmrfAniny

      buying generic viagra online http://usggrxmed.com/ <a href="http://usggrxmed.com/#">viagra online india</a> generic viagra usa

      回复
    • JildcAniny

      comprar viagra online http://fmedrx.com/ <a href="http://fmedrx.com/#">viagra online without pre</a> generic viagra canada

      回复
    • generic viagra online canada

      Herpes is more likely to reproduce in people with weak immune systems.
      <a href="http://siviagmen.com/">generic viagra online canada</a> is it illegal to buy viagra online

      回复
    • Stephenpeaky

      viagra otc <a href=" http://sild100fast.com/# ">viagra without prescription</a> order viagra online

      回复
    • brand cialis online

      Propecia Sin Efectos Secundarios Ovekly https://cialisse.com/ - Cialis DICIVE Co Oppone <a href=https://cialisse.com/#>cialis generic tadalafil</a> immazy Healthy Men Viagra

      回复
    • can you buy cialis online

      Cialis In Apotheke Ovekly https://asocialiser.com/ - buy real cialis online DICIVE Levitra Effetti Lungo Termine Oppone <a href=https://asocialiser.com/#>cheap cialis online canadian pharmacy</a> immazy Levitra Medications

      回复