chklnks - locates and optionally removes broken symbolic links.
chklnks [[[ -a ]| [ <directory> ... ]] [ -d ] [ -h <hostid|> ] [ -r ] [ -v ]]| [ -V ]
chklnks is a Bourne shell script which should work equally well on all versions of UNIX and Linux.
The script chklnks, runs " find " to locate files which are symbolic links where the target file is missing
By default the path and file name of any broken link found are echoed to to " standard out ".
The script is mostly usefully invoked by " cron " to a regular weekly schedule.
-a Check all the local read write filesystems on the target host
-d Set the script to debug mode.
-h
<hostname>
Run the script on a remote host.
-r Broken symbolic links are removed.
-v Set the operation mode of the script to verbose. In verbose mode chklnks will report any broken symbolic links and their removal to standard out .
<directory> If given on the command line <directory> is the starting point for the find. Multiple space separated directories may be listed on the command line.
If no <directory> is nominated on the command line the current directory is is used as the starting point.
chklnks
From the current directory search recursively for broken symbolic links and report any found to /fIstandard out/fR.
chklnks -v -r /src/merlin/usr/local/web
Starting from /src/merlin/usr/local/web do a recursive search for broken symbolic links and remove them. Report each file deleted to standard out.
/usr/local/etc/chklnks.cf.
The script has no input error checking. I'm a bit worried about what happens if filenames with white space in them are found. These names will be passed to rm as multiple file names which could potentially match real files!
Clifford W Fulford of City Linux.
Offering systems management and support for
Linux, Windows and Apple environments. Contact fulford@fulford.net or +44 (0)709 229 5385.
Copyright
© 2003-2017
Clifford W Fulford.
Fulford Consulting Ltd.
Regd. Co. 4250037 in England & Wales.
Regd. office 162, Edward Rd. Nottingham NG2 5GF, England, UK.
Related web sites: City Linux | Flare Support | West Bridgford | Fulford Portal | Joan Mary Fulford (Nottingham Writer) | Fulford Gallery | Amharic Interpreter | Arabic Interpreter | Tigrinya Interpreter
The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.