Bug 3146
Summary: | tmpwatch does not delete directories in temporary directories | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | vectro |
Component: | tmpwatch | Assignee: | David Lawrence <dkl> |
Status: | CLOSED WORKSFORME | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 6.0 | CC: | wms |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 1999-08-30 20:28:50 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
vectro
1999-05-29 21:24:48 UTC
I configured a stock 6.0 machine is the manner reported by the user. I then ran /usr/sbin/tmpwatch 0 /tmp /var/tmp /var/catman/cat? on the command line which is identical to the line in /etc/cron.daily/tmpwatch except is set to go off in 0 hours instead of 240 hours. The tmpwatch script correctly removed all directorys and files properly. This was tested with tmpwatch-1.7-1 ------- Additional Comments From 06/08/99 01:54 ------- I have found that the problem is actualy caused by tmpwatch looking inside the directories, and thus affecting their atime. This is unaffected if tmpwatch is looking for directories that are 0 hours old. I am currently looking into writing a patch to this. One way to do it would be to optimize by assuming that a directory with a hard link count of 2 is empty, but this dosen't work on all filesystems. A better fix would be to either simply delete all empty directories (as the patch to the tmpwatch script I provided does), or to notice the atime for a directory *before* stepping into it. Same thing with tmpwatch-1.7-2, tmpwatch doesn't delete old empty directories yet ... Look into this again with 1hr instead of 0hr I have no problems with 6.0 tmpwatch removing empty directories. Here's an interactive test run: [pbrown@dionysus tmpwatch]$ touch -r /boot/map /tmp/testdir [pbrown@dionysus tmpwatch]$ !stat stat /tmp/testdir/ File: "/tmp/testdir/" Size: 1024 Filetype: Directory Mode: (0775/drwxrwxr-x) Uid: ( 2180/ pbrown) Gid: ( 2180/ pbrown) Device: 3,1 Inode: 32349 Links: 2 Access: Tue Aug 24 16:03:19 1999(00006.00:22:48) Modify: Tue Aug 24 16:03:19 1999(00006.00:22:48) Change: Mon Aug 30 16:26:05 1999(00000.00:00:02) [pbrown@dionysus tmpwatch]$ touch -r /boot/map /tmp/testdir/foo [pbrown@dionysus tmpwatch]$ stat /tmp/testdir/ File: "/tmp/testdir/" Size: 1024 Filetype: Directory Mode: (0775/drwxrwxr-x) Uid: ( 2180/ pbrown) Gid: ( 2180/ pbrown) Device: 3,1 Inode: 32349 Links: 2 Access: Tue Aug 24 16:03:19 1999(00006.00:23:00) Modify: Mon Aug 30 16:26:15 1999(00000.00:00:04) Change: Mon Aug 30 16:26:15 1999(00000.00:00:04) [pbrown@dionysus tmpwatch]$ touch -r /boot/map /tmp/testdir [pbrown@dionysus tmpwatch]$ stat /tmp/testdir/ File: "/tmp/testdir/" Size: 1024 Filetype: Directory Mode: (0775/drwxrwxr-x) Uid: ( 2180/ pbrown) Gid: ( 2180/ pbrown) Device: 3,1 Inode: 32349 Links: 2 Access: Tue Aug 24 16:03:19 1999(00006.00:23:19) Modify: Tue Aug 24 16:03:19 1999(00006.00:23:19) Change: Mon Aug 30 16:26:37 1999(00000.00:00:01) [pbrown@dionysus tmpwatch]$ sudo ./tmpwatch -v 24 /tmp removing file testdir/foo removing directory testdir The file and the directory get removed properly. 6.1 tmpwatch (v2.0) will also support a --atime or --mtime option, so files may be removed depending on what sort of time you are interested more in. I'm using RH6.2, and see the same problem - tmpwatch doesn't delete directories, not ever. I think I know the problem, and the "works for me" above doesn't test it: every day, tmpwatch scans the /tmp tree for files to remove. That means that every day, the "atime" of every directory of /tmp gets updated. Since tmpwatch as configured by RH6.2 doesn't delete a directory until it's atime is 7 days old, that means directories simply never get deleted. For tmpwatch to be useful for deleting directories, it can *never* use atime. It at the very least needs to add a switch for "use atime for files, mtime for directories". Or maybe a switch for "delete empty directories with a ctime of over 7 days"...that way, the directory will last until they have been around for seven days and are empty, which seems a good criteria for removal. |