Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX sample scripts - chklnks

NAME

chklnks - locates and optionally removes broken symbolic links.

SYNOPSIS

chklnks [ -a ] [ -d ] [ -h <hostid|> ] [ -r ] [ -V ] [ -v ] [ <directory> ... ]

AVAILABILITY

chklnks is a Bourne shell script which should work equally well on all versions of UNIX and Linux.

DESCRIPTION

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.

OPTIONS

-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.

EXAMPLES

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.

FILES

/usr/local/etc/chklnks.cf.

BUGS

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!

SEE ALSO

chkdf, chkftpd, chkfw, clean.

AUTHOR

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.


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.