I wrote a script that scans a folder for new files.
I don't want to run it at specific times but only when the computer is NOT busy.
I tried to use nice but it doesn't really work. I mean, even if my process has less priority, it still slows down the other processes. I did a test to check that. The following command creates a dummy file of 256 MB: It lasts 20 seconds
If I run this command two times at the same time, one in normal mode, the other one with nice, I get the following times: normal=35 seconds
niced=45 seconds
What I'm trying to do is that one command runs without being slowed down and the other command simply waits untill it can run without slowing down other processes.
Am I clear enough? Don't hesitate to ask for more information if you can help me.
There's a small logical error in your example: nice only advises the process scheduler, and a high niceness doesn't mean that the process will wait 'till nothing else is running. It just means that those processes with a lower niceness will run first, and after they're done or waiting it'll get CPU time just like the others.
Besides, the example you've given is probably more influenced by I/O waits of 2 (or more) processes accessing the HDD than the scheduler.
As for your problem, you could check the first or second field of /proc/loadavg (1 / 5 minute load average), and depending on that start your process. It can't, however, predict whether or not another, CPU intensive, process will start just 5 seconds after.
Other than that you could look for periods of time where the system is almost idle, and only allow your program to run during those periods. But that would have to be done manually, as it's non-trivial to code (IMO). Software like BOINC just wait for a certain time of no user input to determine "idle".
Or, if you know that the process will be very CPU intensive for a short period of time, start it with a very low niceness, so that impact on the system will be as short as possible.
I would like to run a command if my computer is idle.
I found this, but is not quite working.
#!/bin/sh
idletime=$(xprintidle)
threshold=300000 # 5 min = 5 * 60 * 1000 ms
if ; then
echo "idle for 5 minutes."
fi (4 Replies)
I noticed when having some trouble with code I was testing that the CPU was becoming exhausted and I would have to reboot. After rebooting a couple times I decided to check for other problems before trying my code again. That's when I noticed that the CPU with the idle process was through the roof:... (5 Replies)
Hi,
I need a script that can automatically kill all processes named "webrepn" and "webrebw" if idle for more than 30 minutes.
Then I will have a Cron Job to run the script every night or 2-3 times a day depends on how this script helps.
Right now, I run "ps -ef | grep webrebn" and "kill -9... (7 Replies)
Hi Everybody,
Can anybody explain how CPU idle% is about 50%, but runq-sz more than 1?
sar from Solaris 10:
00:00:05 %usr %sys %wio %idle
17:00:08 27 12 0 61
17:20:05 40 15 0 45
17:40:05 27 12 0 61
18:00:05 23... (2 Replies)
Dear Friends ,
I am using DB2 database in AIX 5.3 server . In my server some IDLE process are generated after several times which I need to kill it manually each and every time .
The process I query like following :
root@bagpuss $ ps auxw|sort -r +3|head -10
USER PID %CPU %MEM ... (3 Replies)
We are running AIX 5.3 and for ICICS Printing we have process called cicstermp runing whcih attaches the print to print queue
But is process is triggered when ever a print is to be given
Can we find the processes which are idle
I mean every time a print is given it creats a new cicstermp... (1 Reply)
Matez,
I have a list of process id's in a text file. I want to know how to find the idle time of a process which are more than 300secs and kill them accordingly.
Could you please help me to get these details. I want to write a shell script with this.
Thanks..Krish :) (36 Replies)