First of all, install symlinks if it is not installed :
sudo yum install symlinks
and here is the description:
Description : The symlinks utility performs maintenance on symbolic links.
: Symlinks checks for symlink problems, including dangling symlinks
: which point to nonexistent files. Symlinks can also automatically
: convert absolute symlinks to relative symlinks.
: Install the symlinks package if you need a program for maintaining
: symlinks on your system.
and the help for the same:
symlinks: scan/change symbolic links – v1.3 – by Mark Lord
Usage: symlinks [-cdorstv] dirlist
Flags: -c == change absolute/messy links to relative
-d == delete dangling links
-o == warn about links across file systems
-r == recurse into subdirs
-s == shorten lengthy links (displayed in output only when -c not specified)
-t == show what would be done by -c
-v == verbose (show all symlinks)
So, if you want to delete all the invalid symlinks in the current directory the just execute:
symlinks -d .
symlinks -d -r .
Here is a simple script that will list out all the paths in the PATH variable that do not exist.
# FILE: wrong_path.sh
# USAGE: ./wrong_path.sh
# DESCRIPTION: Show Directories in the PATH Which does NOT Exist
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Amit Agarwal (AKA), [email protected]
# COMPANY: Individual
# VERSION: 1.0
# CREATED: 09/20/2009 09:15:48 AM IST
# REVISION: ---
set -o nounset # Treat unset variables as an error
(IFS=:;for p in $PATH; do test -d $p || echo $p; done)
$ strace php tias.php -e open,access 2>&1 | grep foo.txt Sometimes a program refuses to read a file and you\’re not sure why. You may have display_errors turned off for PHP or something. In this example, fopen(\’/var/www/test/foo.txt\’) was called but doesn\’t have read access to foo.txt.
Strace can tell you what went wrong. E.g., if php doesn\’t have read access to the file, strace will say \”EACCESS (Permission denied)\”. Or, if the file path you gave doesn\’t exist, strace will say \”ENOENT (No such file or directory)\”, etc.
This works for any program you can run from the command-line, e.g., strace python myapp.py -e open,access…
Note: the above command uses php-cli, not mod_php, which is a different SAPI with diff configs, etc.
by David Winterbottom (codeinthehole.com)