November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

How to find dead links and delete them

Sometimes, after performing VPS migrations, the soft links in /etc/vz/conf may not be removed. Over time, the dead links may build up and cause many ‘No such file or directory’ messages when trying to look for common settings amonst all conf files (ie cat /etc/vz/conf/*.conf | grep whatever).
Quick easy way to delete these dead links:

~# cd /etc/vz/conf
~# for f in `find . -type l ! -exec test -r {} \; -print`; do rm -f $f; done

One liner:

~# find -L -type l -exec rm -f {} \;
* Please test before issuing these commands on production systems!!

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>