Speedkill – Perl Script to hunt and kill selected PIDs

If you ever run a selection of applications or processes and regularly get lock-ups due to a lack of processing power or RAM. This script allows you to add a selection of non-essential apps to a list which can be knocked-out if resources are running low.

Just copy and paste this script to a file called “speedkill” in /usr/local/bin or your /home/user/bin, make it executable, and then you can run it from the terminal if things start to get a bit “iffy” 🙂 Just edit the line “my $processes = “google-chrome claws-mail conky volwheel”;” and add any apps you can do without.


###########################################
# DESCRIPTION:
#
# This script will kill a bunch of
# expendible processes if your system
# gets frozen.
#
###########################################
# PERL MODULES TO USE
###########################################
# NONE
#use NOTHING
###########################################
# Debugging:
use strict;
use warnings;
###########################################
#Let's tell the user the carnage they are about to inflict
#
print "Hunting down enemy PIDs...\n";
#
#Then we need to find the PIDs of expendable apps

#for my $file (@ARGV) {
my $processes = "google-chrome claws-mail conky volwheel";
my @processes = split (" ", $processes);
for my $process (@processes) {
open (PID, "pidof $process |");
while ($_ = ) {
my @list = split (" ", $_);
for my $pid (@list) {
print "Killing pid $pid ($process)\n";
system ("sudo kill -9 $pid");
}
}
close PID;
}

print "Like lambs to the slaughter!\n";

Advertisements

Adding Windows guides to my Linux blog

I k now it may seem strange to to start seeing Windows based Howto guides on a predominantly Linux blog, but the truth is after so long without having to fix Windows machines I am gradually forgetting all the old tweaks and fixes that come part and parcel with running a slow, inconsistent, unreliable operating system 🙂

I work as a Debian server IT admin for a company with various international clients, and although we provide and maintain Debian based clusters and servers, we also occasionally offer general support for certain clients. It’s not the norm (thankfully), but we do also get requests to help out with Windows desktop and server problems.

Hence the reason I will be adding a few tweaks and guides to my blog for safe-keeping and quick reference.

Up until about 2000/2001 I had Windows (Xp) on my laptop and a few other machines, and I constantly strived for better performance and security. Talking of performance, I managed to get Xp to run quite well on an old Toshiba Satellite that came with Windows ME installed. It only had a 650hz processor and 64Mb RAM, and somebody made the mistake of commenting that it would be “impossible” to run Xp on that laptop. Well, it only stands to reason that I would eventually end-up running and working with Linux, as the tweaking/hacking bug took hold.

Funnily enough that little Toshiba Satellite survived 6 years of Linux Distro-Tests and finally met it’s demise in 2007 *lump in throat, tear in eye* It survived Mandrake, Suse, Debian and from 2004 (Hoary) to 2007 (Dapper) was running nicely on Ubuntu, although it had multiple partitions on its little 6Gb hard-drive for distro tests.

Before changing to Linux, I used to tweak the hell out of Windows and regularly had to reinstall or create partitioned test installs, and it’s amazing the little tricks you learn with scripts, apps, editing the registry and tweaking the Windows default services. I used to know most of them by heart, but unfortunately (?), over the years I have forgotten many of those little Gems and have decided I need to have a little storage area on my blog to provide support for the uncleaned masses who still use this poor excuse for an operating system.

Incidentally, I do have an Xp install at home that is only used as a gaming machine, it does NOT have an internet connection, and only serves one purpose 😉

So there you go, an explanation as to why Windows material will be cropping up on my Linux blog,

Windows longer http keep-alive timeout

This article describes how to change the default HTTP keep-alive value

When Internet Explorer establishes a persistent HTTP connection with a Web server (by using Connection: Keep-Alive headers), Internet Explorer reuses the same TCP/IP socket that was used to receive the initial request until the socket is idle for one minute. After the connection is idle for one minute, Internet Explorer resets the connection. A new TCP/IP socket is used to receive additional requests. You may want to change the HTTP KeepAliveTimeout value in Internet Explorer.

If either the client browser (Internet Explorer) or the Web server has a lower KeepAlive value, it is the limiting factor. For example, if the client has a two-minute timeout, and the Web server has a one-minute timeout, the maximum timeout is one minute. Either the client or the server can be the limiting factor.

By default, Internet Explorer has a KeepAliveTimeout value of one minute and an additional limiting factor (ServerInfoTimeout) of two minutes. Either setting can cause Internet Explorer to reset the socket.

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows

You may have to increase the default time-out value for persistent HTTP connections in Internet Explorer if you are using a Web program that must communicate with Internet Explorer over the same TCP/IP socket after one idle minute. To change the default time-out value for persistent HTTP connections in Internet Explorer, add a DWORD value that is named KeepAliveTimeout to the following registry key, and then set its value data to the time (in milliseconds) that you want Internet Explorer to wait before resetting an idle connection:

To do this, follow these steps:
1. Click Start, click Run, type regedit, and then click OK.
2. Locate and then click the following key in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
3. On the Edit menu, point to New, and then click DWORD Value.
4. Type KeepAliveTimeout, and then press ENTER.
5. On the Edit menu, click Modify.
6. Type the appropriate time-out value (in milliseconds), and then click OK. For example, to set the time-out value to two minutes, type 120000.
Restart Internet Explorer.

*NOTE*
If you set the KeepAliveTimeout value to less than 60,000 (one minute), you may have problems communicating with Web servers that require persistent HTTP connections. For example, you may receive a “Page cannot be displayed” error message.

*NOTE 2*
If you must have a KeepAliveTimeout value higher than 120000 (two minutes), you must create an additional registry key and set its value equal to the KeepAliveTimeout value that you want. The additional registry key is ServerInfoTimeout. It is a DWORD with a value (in milliseconds) and in the same location as KeepAliveTimeout.

For example, to use a three-minute KeepAliveTimeout value, you must create the following registry keys:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings

KeepAliveTimeout DWORD value 180000 (in milliseconds)
ServerInfoTimeout DWORD value 180000 (in milliseconds)

By default, HTTP 1.1 is enabled in Internet Explorer except when you establish an HTTP connection through a proxy server. When HTTP 1.1 is enabled, HTTP connections remain open (or persistent) by default until the connection is idle for one minute or until the value that is specified by the KeepAliveTimeout value in the registry is reached. You can modify HTTP 1.1 settings in Internet Explorer by using the Advanced tab in the Internet Options dialog box.