Month: August 2014

How to resolve the ‘/bin/rm: Argument list too long’ error

While you are deleting some files which fill up your disk you may hit -bash: /bin/rm: Argument list too long error message.

So you can use below syntax to can delete those files:
# find . -name "DIR_PATH/*" -type f -exec rm -f {} \;
# find DIR_PATH -name "*" -type f -exec rm -f {} \;

You can also delete files with a specific extension (ex.: .php):
# find DIR_PATH -name "*.php" -type f -exec rm -f {} \;
# find . -name "DIR_PATH/*.php" -type f -exec rm -f {} \;

PS: In our case DIR_PATH=/var/spool/postfix/maildrop (there are like a half million files in that directory).

How to find the number of files on a filesystem?

For some reason df -h command shows that you have plenty of free space. However your apps keep telling you that you don’t have enough free space. The following will help you identify the problem.

The –inodes option to df will tell you how many inodes are reserved for use. For example:
df --inodes /
Filesystem Inodes IUsed IFree IUse% Mounted on
989296 977987 11309 99% /
find / -xdev -print | wc -l

Notice that the number of entries returned from find is lower than IUsed for the root (/) filesystem.

Remember that directories, symlinks, UNIX domain sockets and named pipes are all ‘files’ as it relates to the filesystem. So using find -type f flag is wildly inaccurate, from a statistical viewpoint.

imagick Cannot locate header file MagickWand.h

For some odd reason I did not understand why imagick 2.3.0 did not want to install with ImageMagick 6.8.9-7. Apparently the directory structure changed in the last versions of ImageMagick.

The solution is pretty simple:
ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick

After this just follow the next steps and you’re in business:
pecl install imagick-2.3.0.tgz

I’m running PHP 5.3.28, however keep in mind that this particular version of imagick (2.3.0) won’t work in PHP 5.4 and higher.