in reply to (OT) Run task only when resources have been free for x time

Why would you not have the script run all the time, periodically checking the resources in question, and running whenever you feel resources are 'free' enough. For Linux, you can use Sys::Load to get load average. You can use the Linux free command to evaluate available memory.
  • Comment on Re: (OT) Run task only when resources have been free for x time

Replies are listed 'Best First'.
Re^2: (OT) Run task only when resources have been free for x time
by leocharre (Priest) on Nov 12, 2008 at 15:03 UTC
    free is cool- but.. it just shows you memory usage. There's a ton of stuff that uses little memory but will flirt excessively with the cpu.
      I mentioned free because you did not indicate which resources were important to you. If cpu is the overriding factor, then Sys::Load is probably your best bet. Load average is the best generalized mechanism for gauging CPU utilization. When this number exceeds 1, it means there are more threads/processes waiting to run than are able to. On a single CPU system, if all 3 average values are greater than 1, then the system is experiencing sustained load.

      It might be enough to see all 3 load values be less than 1. Of course, this is all backward-looking. It is a little trickier to start your 'hog' process, and then have something more important decide it needs to run.