Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So cron or at can schedule our commands to run at the exact time we need them to, but can we schedule commands to run when systems are inactive?

Something like:

echo "some_commands" | when 'cpu < 15%' 
share|improve this question
you have to be more specific: what is the purpose of some_command? – hop Sep 13 '10 at 23:11
from your question it is not clear whether you talk about seti@home or some delayed maintenance script. – hop Sep 14 '10 at 7:44
a script to run when the pc isn't too busy.... – Stefan Sep 14 '10 at 9:09
no hop, im not trying to be thick nor am I trying to be rude. I'm going assume my question is clear enough as the 3 answers recieved are all spot-on. – Stefan Sep 14 '10 at 11:47
This is a good question @Stefan. At my previous job we ran alot of load-dependent Oracle batch jobs using DBMS_JOB, and it's common to only run jobs when the load falls below a particular level. I often wished we could do this well using cron, but we only came up with hackish solutions. – Stefan Lasiewski Sep 20 '10 at 23:13
up vote 1 down vote accepted

hmmm... I don't think so... but what you could do is cron a script to run like every 5 minutes and check the load average to see if it's acceptably low. I wouldn't check the current because you could get the cpu in between 2 really high peaks. This is just thoughts on what I'd do to accomplish this, but there might be a better way.

share|improve this answer
Keep in mind that uptime reports load averages for three different intervals (last minute, last five minutes and last fifteen minutes). In general load average is only the average number of items in the run queue during that time interval. On some systems (Linux in particular) processes in "D" state are counted as runnable. So a system with processes waiting on a slow (or missing) NFS server can appear to have a large load average that has nothing to do with real load on the system. – Jim Dennis Sep 14 '10 at 3:49

Fcron has a lot of additional features over common cronds. For example:

  • set the max system load average value under which the job should be run

(quote from the Homepage)

Thus, you could use fcron to setup what you want.

share|improve this answer

On many systems the at daemon is configured such that the batch command will run a command when the system drops below a certain load. However, this may not give you the fine grained control you are looking for.

share|improve this answer
From 'man batch' on my Fedora 14 system: batch executes commands when system load levels permit; in other words, when the load average drops below 0.8, or the value specified in the invocation of atd. – dr-jan Feb 10 '11 at 11:48

A friend of mine posted about this problem some days ago. He talks about this tool Dmon. I did not test it, but it sounds great.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.