I am relatively new to UNIX and wanted to accomplish a simple task which should be automated. That's why I need your help. I shall briefly describe what I want.
Basically, there is a process (X) (related to a particular software which I am using in my system) which automatically starts after some time and eats up a lot of resources resulting in slowing up other necessary processes running. So all I want is to -
STEP-1: periodically (it is better if I can set the the interval duration) check whether process-X has started or not
STEP-2: obtain the PID of the process-X
STEP-3: execute: "kill -9 <PID of process-X>"
And these three steps, I want to write as a script and that script should automatically check the status of process-X and take necessary action as long as my system is up.
Instead of repeatedly killing process (X); why not just use nice when you start it so it will run at a lower priority and use less system resources when your necessary processes are running at normal priority.
The problem here is - process X does not get initiated by the user, it is started from within another master process which is the main design software (installed in our company's server, so I don't have much access to that other than launching it and working on it) I am using in my system. Now, I don't know on what basis process X is started. So, everyday morning, I used to kill process X and continue with my work. If am in front of my workstation, I can manually check the status of process X and kill it whenever necessary. However, if it starts overnight then it slows don the progress of other simulations being run in the main software. So, I wanted to have a local work around to this problem so that what I am doing manually (when I am in front of the workstation) can be done automatically. And I don't have to bother about it forever
DESCRIPTION
renice alters the scheduling priority of one or more running processes.
The first argument is the priority value to be used. The other argu
ments are interpreted as process IDs (by default), process group IDs,
user IDs, or user names. renice'ing a process group causes all pro
cesses in the process group to have their scheduling priority altered.
renice'ing a user causes all processes owned by the user to have their
scheduling priority altered.
When you are in front of your workstation and manually kill process X, please show us exactly what commands do you type into your shell to kill process X (in CODE tags). If you want a script to replace what you're doing manually, it is always great to actually know what you do manually! Show us the output produced by each step. Tell us what you use from each step as input to the next step.
Do you really have to use kill -9 PID ? Doesn't kill PID work?