April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

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>