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.