About automatic deletion of files under Linux tmp

Source: Internet
Author: User

Recently found that there is a machine tmp placed under the innocent loss of files, and the detection is automatically lost, and, just delete files 10 days ago ....


I thought it was the one who wrote an auto-execute script, find the file deleted 10 days ago ....



As a result, the crontab schedule for all users is cleared, and no user has executed the automatic script



Monitored the server login, and no one logged in during the deletion of the file



Finally, through unremitting Baidu, finally found a positive solution


It is found from the/var/log/cron log that the server executes its own system in addition to the user's scheduled tasks, such as:

/etc/cron.hourly

/etc/cron.daily


Enter/etc/cron.daily


Can see a Tmpwatch


Cat Tmpwatch


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 240/tmp

/usr/sbin/tmpwatch "$flags" 720/var/tmp

For D In/var/{cache/man,catman}/{cat?,x11r6/cat?,local/cat?}; Do

If [-D "$d"]; Then

/usr/sbin/tmpwatch "$flags"-F 720 "$d"

Fi

Done


You can see that a script called Tmpwatch is called, and we can see that the incoming parameters are meaningful to us./tmp 240


And then we man Tmpwatch


Synopsis

Tmpwatch [-u|-m|-c] [-MUADFQSTVX] [--verbose] [--force] [--all]

[--nodirs] [--nosymlinks] [--test] [--fuser] [--quiet]

[--atime|--mtime|--ctime] [--dirmtime] [--exclude <path>]

[--exclude-user <user>]

There is a hours


240 = 10*24 The whole good is 10 days


The specific reason is that TMP is a special folder, the system will automatically clean up, so it is best not to put the files in this place, was cleaned up is not good


About automatic deletion of files under Linux tmp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.