1

we want to delete all abrt folders from /var/spool/abrt/

before we just run the following , to see how many folders we have

find /var/spool/abrt/  -type d
/var/spool/abrt/
/var/spool/abrt/ccpp-2019-09-10-08:05:21-1652

now we runs this to clean the abrt folders

 find /var/spool/abrt/  -type d   -exec abrt-cli rm '{}' \;
'/var/spool/abrt' is not a problem directory
Can't delete '/var/spool/abrt/': (null)
rm '/var/spool/abrt/ccpp-2019-09-10-08:05:21-1652'
find: ‘/var/spool/abrt/ccpp-2019-09-10-08:05:21-1652’: No such file or directory

and simple verification

 find /var/spool/abrt/  -type d
/var/spool/abrt/

note - no folders

but as we can see from command find /var/spool/abrt/ -type d -exec abrt-cli rm '{}' \; output we get also

'/var/spool/abrt' is not a problem directory
find: ‘/var/spool/abrt/ccpp-2019-09-10-08:05:21-1652’: No such file or directory

just want to be sure if I have something wrong with - find /var/spool/abrt/ -type d -exec abrt-cli rm '{}' \; ?

muru
  • 69,900
  • 13
  • 192
  • 292
yael
  • 12,598
  • 51
  • 169
  • 303

1 Answers1

2

In your output,

'/var/spool/abrt' is not a problem directory
Can't delete '/var/spool/abrt/': (null)

is shown because your find command matches /var/spool/abrt itself, as well as its subdirectories.

find: ‘/var/spool/abrt/ccpp-2019-09-10-08:05:21-1652’: No such file or directory

is shown because find tries to descend into that directory, even though abrt-cli has removed it.

To avoid the first, tell find you want a minimum depth of 1; to avoid the second, prune the directories you delete:

find /var/spool/abrt/ -mindepth 1 -type d -exec abrt-cli rm '{}' \; -prune
Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164