January 2026
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  

Categories

January 2026
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  

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>