Posts Tagged ‘process’
Monitor Processes With Windows PowerShell
Maybe you have already come across applications that require you to rearrange things on your desktop for optimal visibility or which you only use in combination with other programs or items – an automated startup or rearrangement would come handy in those situation.
The following little PowerShell script allows just this – automatical actions on process start and/or end.
$target = “firefox”
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
while ($true)
{
while (!($process))
{
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
start-sleep -s 5
}
if ($process)
{
“Place action on process start here”
$process.WaitForExit()
start-sleep -s 2
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
“Place action on process exit here”
}
}
The script above runs continuously until it is terminated or the current session is ended. With a wait time of 5 seconds to give the CPU a break it checks if the process is running – if not, it continues to check, if yes, it spills out some text you can replace with the action to perform on process start and waits until the process is ended. Afterwards, it returns some text to replace and continues to wait for process start again. Currently, the process that is monitored is firefox and is specified in the $target variable at the top of the code.
To run the script, copy and paste it into a notepad, save it as .ps1 file and schedule it on startup with the Windows Scheduled Tasks service if you like. To run the script completely without pop-ups, have a look here.
Kill Processes On Ubuntu
When it comes to killing a frozen process, Ubuntu and its derivatives offer a great variety of ways to do so:
You can open the System Monitor to end or kill a running process. Just right-click and annihilate:
Then there is the Force Quit applet. Not that powerful, but does its job in most of the cases:
Working similarly but more powerful is the xkill command line tool. You can also wrap that one into a launcher and use it the same way as an applet.
Another command line tool is killall followed by the name of the process, granting the advantage of not having to know the process ID of the program, which the next tool requires:
kill, provided with the -9 switch and the ID of the process (available with top or ps) shuts down nearly every running process.
If none of those commands help, there is still the option to close the current session with ctrl + alt + backspace. This however comes with the warranty of losing any data you could not save before!
How to Kill Processes on UNIX Based Operating Systems
This guide explains how to kill processes on Unix based operating
systems.
To kill a process you need to know its Process ID (PID). To find out that, open a terminal and enter
ps -e
The list of processes has two columns that are important for you, which are PID and CMD. CMD gives you the name of the process whereas PID gives you the ID. Search the list for the process you want to kill and enter
kill -9 PID
Replace PID with the PID of the process you want to kill. This procedure is similar to the one of Windows’ Task Manager.

