On 16 August 2011 14:41, <[log in to unmask]> wrote:
> ATLAS/Alastair have asked are help to see if we can help sites achieve the
> following clean up of empty directories on the SEs:
>
>
>
> https://twiki.cern.ch/twiki/bin/view/Atlas/SquadHowTo#Deletion_of_empty_directories_in
>
>
>
> Now for castor he has this python script:
>
>
>
> #! /usr/bin/env python
> import os
>
> #mcdisk = "/castor/ads.rl.ac.uk/prod/atlas/simStrip/atlasmcdisk"
> emptyDirs = []
>
> def getDirs(path):
>
> dirs = os.popen("nsls -l " + path).read().split("\n")
> dirs.remove("")
> if dirs.__len__() == 0:
> print path
> os.popen("nsrmdir " + path)
> # emptyDirs.append(path)
> return
> else:
> for i in dirs:
> if i[0] == "d":
> # subDirs.append(dirs[i].split()[-1])
> getDirs(path + i.split()[-1] + "/")
> return
>
> getDirs("/castor/ads.rl.ac.uk/prod/atlas/simStrip/")
> #print emptyDirs
>
>
>
>
>
> Just a case of replacing:
>
> “nsls –l” with “dpns-ls –l” ?
>
> “nsrmdir” with “dpns-rm” ?
>
>
>
> Now if I am correct we might need the “–r “ option on the dpns-rm, but isn’t
> this ( dangerously?) recursive?
Yes, in the same sense that unix rm -r is.
There is no equivalent "dpns-rmdir" though, so it's the only option
via the dpns daemon directly.
>
> I am worried that a site might end up deleting everything by mistake.
>
Well, in principle, this shouldn't happen - the script does seem to
carefully not try to delete directories with non-zero contents.
In practice, is it worth using a dummy script first that echoes the
directories it thinks it will be deleting so a human can check it's
working?
Sam
> Brian
|