I found the following on google; you should be able to taylor it to your needs:
http://techtasks.com/code/viewbookcode/567
# This code sets the priority of a process
# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
# "Windows Server Cookbook" by Robbie Allen
# ISBN: 0-596-00633-0
# ---------------------------------------------------------------
use Win32::OLE;
$Win32::OLE::Warn = 3;
use constant NORMAL => 32;
use constant IDLE => 64;
use constant HIGH_PRIORITY => 128;
use constant REALTIME => 256;
use constant BELOW_NORMAL => 16384;
use constant ABOVE_NORMAL => 32768;
# ------ SCRIPT CONFIGURATION ------
$strComputer = '.';
$intPID = 2880; # set this to the PID of the target process
$intPriority = ABOVE_NORMAL; # Set this to one of the constants above
# ------ END CONFIGURATION ---------
print "Process PID: $intPID\n";
$objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer .
'\\root\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
print 'Process name: ' . $objWMIProcess->Name, "\n";
$intRC = $objWMIProcess->SetPriority($intPriority);
if ($intRC == 0) {
print "Successfully set priority.\n";
}
else {
print 'Could not set priority. Error code: ' . $intRC, "\n";
}
----- Original Message ----
From: david <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, August 27, 2008 5:31:15 PM
Subject: Re: [EMAIL PROTECTED] lower cpu priority to perl scripts
Audio Phile:
Do you have a comparable example for ActiveState Perl on Windows?
At 03:12 PM 8/27/2008, you wrote:
>If you are running on unix, the easiest way to probably do this is
>by calling the "setpriority" from within your perl script like this:
>setpriority(WHICH,WHO,PRIORITY);
>To set your current running perlscript to the lowest priority, you
>would call setpriority(0, $$, 20);
>$$ is your script's process ID, and "20" denotes the priority. (as
>you know, -20 is highest priority and 20 the lowest priority).
>Cheers,
> R.
>
>----- Original Message ----
>From: Audio Phile <[EMAIL PROTECTED]>
>To: [email protected]
>Sent: Wednesday, August 27, 2008 2:18:53 PM
>Subject: Re: [EMAIL PROTECTED] lower cpu priority to perl scripts
>
>Tamer,
>
>Thank you very much for the reply. I googled around for the proper
>syntax of your suggestion as well as which config file I need to
>edit with it, but I came up with a big fat 0. Can you provide a few
>more details for me? Apologies in advance, I am a newbie with apache2 :)
>
>Tamer Embaby wrote:
>Audio,
>
>You can always start your scripts with [re]nice() syscall to lower
>your process (perl script in this case) priority.
>
>Regards,
>Tamer
>
>-----Original Message-----
>From: Audio Phile [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, August 26, 2008 8:57 PM
>To: [email protected]
>Subject: [EMAIL PROTECTED] lower cpu priority to perl scripts
>
>I'd like to adjust the priority of /usr/bin/perl such that it will
>always run with very low priority. The PC that I'm using isn't very
>powerful. I'm running rrdweather on it and when a user hits the
>weather.cgi about 10 processes of perl scripts run,
>which totally throttles foreground applications until they finish.
>
>How can I assign /usr/bin/perl to always run with a really low CPU
>priority (a really high nice value) for any script it executes? Is
>this an apache2 setting or...?
>
>
>
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: [EMAIL PROTECTED]
> " from the digest: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: [EMAIL PROTECTED]
> " from the digest: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]