André Figueira

Systems engineer - I write apps, I make websites, opinions are my own...

Delete all symlinks in a folder

Recently I've been setting up some really cool stuff, namely some queue workers and consumers which are run by SupervisorD and I've been crafting a way of automatically updating my config.

So I came up with a simple solution that involves having the include enabled in SupervisorD, this will automatically add included files in a directory as part of the SupervisorD config. I'll cover this in another post.

All I needed was a way to delete existing symlinks, in a nice soft way, so find with the -delete and -lname flags will sort me out!

find /path/to/the/symlinks -lname '/something/which/match/the/symlinks*' -delete

This will simply look for symlinks matching your search and delete them. I use this within a Capistrano task to update my SupervisorD configs with any changes from the repository, meaning my SupervisorD config is versioned, in addition Capistrano also runs a reread, update and restarts my workers upon successful deployment.