Top Nav

Archive | Scripting

getpass.sh Bash Script

Simple bash script for generating random passwords. We didn’t write this and don’t know exactly where it came from.

 

0

Apache Watch Script

Here’s a trivial old script that I sometimes use to monitor for rough processes running on the apache user:

 

0

To Many PHP Session Files

I seen several servers with high traffic PHP sites hosted on Plesk servers building up an excessive number of PHP session files in /var/lib/php/session. Typically we discover this problem when the server runs out of inodes on the root filesystem.

Plesk provides a cronjob that runs hourly to clean up PHP session files:

For low traffic sites this script work just fine. But for high traffic sites with thousands of sessions per hour the script is too slow and can’t keep up with the rate that files are created.

The problem is the script check each files using the “fuser” utility to determine if the file is in use. This is a slow process. So on these high traffic servers I’ve found it necessary to remove the “fuser” check. Edit /etc/cron.hourly/plesk-php-cleanuper and change this line:

to:

Now the session cleanup will run smoothly.

0

Apache mod_fcgi on CentOS 6.4

There are a lot of tutorials on how to install mod_fcgi with suexec out there but many are incomplete, outdated or just don’t work. One that does work is here:

http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-centos-6.2

 

0

How-to Cut With Multi-Character Delimiter

The “cut” command is great for splitting a string on a single character and extracting specific fields. But it will not work with multi-character delimiters. Here’s a simple replacement using awk that will get the job done. Let’s assume you have a string like:

We could extract the value of “arg3” using cut with:

But this assumes that there are always the same number of proceeding args:

Now lets do it with awk:

But what if the args are in different order? The we can use sed:

 

1