1

Wildcard does not seem to work in exclude path provided to tmpwatch.

I have following dir structure inside /tmp

drwxr-xr-x  2 vrisbud developers    4096 May 17 15:36 AssetEnumeratorTest
drwxr-xr-x  2 vrisbud developers    4096 May 17 15:37 EnumeratorReducerTest
drwxr-xr-x  2 reco    reco          4096 May 30 14:42 hadoop-reco
drwxr-xr-x  3 vrisbud developers    4096 May 17 15:30 hadoop-vrisbud
drwxr-xr-x  2 reco    reco          4096 May 31 08:10 hsperfdata_reco
drwxr-xr-x  2 root    root          4096 May 26 13:30 hsperfdata_root

I want to exclude the dir starting with 'hadoop' from tmpwatch. So I am executing the following command

tmpwatch -tmf 8 -x /tmp/hadoop* /tmp

It shows that it will delete 'hadoop-reco' and 'hadoop-vrisbud' directories. (I am just testing it so I have -t flag added to it.)

I also tried

tmpwatch -tmf 8 -x '/tmp/hadoop*' /tmp
tmpwatch -tmf 8 -x '/tmp/hadoop.*' /tmp

Nothing seems to work. I want to exclude directories starting with 'hadoop' from tmpwatch.

I am using tmpwatch 2.9.7 version if that makes any difference.

I would like to know how I can do it on my current version of tmpwatch. As an answer below indicates that I can use the -X option in the upgraded version of tmpwatch, but I don't have this option available in my current version.

1

Is upgrade (or compile from source) an option? Don't know which version first added this option; my (centos 6.6) man-page for tmpwatch 2.9.16 has:

-X, --exclude-pattern=pattern
  Skip paths matching pattern; if a directory matches pattern,
  all files contained in it are skipped too. pattern must match
  an absolute path that contains no symbolic links.

Edit: Brute force for older versions may be like (use shell globing and printf in backquotes or similar to generate the -x ... arguments):

tmpwatch -tmf 8 /tmp `printf -- "-x %s " /tmp/hadoop*/`

Note: Trailing space in printf format string is required. And as written it does not exclude hadoop* in sub-directories.

  • This is the correct way to do it. I saw it on different posts online but I would like to see how I can do it in my current version of tmpwatch. The reason being I don't have the rights to upgrade the tmpwatch version on the server. I can ask my sysadmin to do it if this is the only option. – Varun Risbud Jun 1 '17 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.