Clean the local scratch space

Sometimes you want to get rid off all temporary stuff you left on any compute node (e.g. you just finished a big search, all results are stored in your home and you just want to be nice to other users and give them more space to breath).

The brutal way

Just run this from any head node (atlas1, atlas2, ...) - CAVEAT this will delete all files under your local directory on any compute node!

dsh -aMF50 'cd /local/user/`whoami` && ls | xargs -r rm -rf'

What will this do?

  1. dsh will launch 50 parallel ssh sessions (-F50) to all compute nodes (stored under /etc/dsh/machines.list, option -a) and will display the output of any command prefixed with the node's name (-M).
  2. on each node, the shell is instructed to change into the directory /local/user/`whoami`, where `whoami` will return automatically your user name and relieve me from writing this tutorial once for every user we have wink
  3. in this directory it will call ls and pipe the output to xargs. If there is any input it will call rm -rf with the maximal number of arguments possible and repeat this until all files and directories are gone.

The more cautious way

dsh -aMF50 'find /local/user/`whoami` -mtime +1 -type f -mindepth 1 | xargs -r rm -f; \
find /local/user/`whoami` -mtime +1 -type d -mindepth 1 | xargs -r rmdir'

This command will also run 50 parallel "threads" on the cluster, while first finding and removing all files (-type f) under /local/user/`whoami` which are at least 1 day old (-mtime +1). The second part will then delete all directories which are empty and also more than a day old (Thanks ChrisP for the suggestion)

-- CarstenAulbert - 15 Apr 2010

DocumentationForm edit

Title Clean the local scratch directories of compute nodes
Description With a simple command you can clean your scratch space on all Atlas' compute nodes
Tags clean, dsh, xargs
Category User
This topic: ATLAS > WebHome > GeneralDocumentation > CleanLocalScratch
Topic revision: 10 Feb 2012, ArthurVarkentin
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback