Putting a value on the load of a windows system
I've written an image processing script in php which is run as a cron scheduled task (in OSX). To avoid overloading the system, the script checks the system load (using 'uptime') and only runs when load is below a predefined threshold.
I've now ported this over to Windows (2003 Server) and am looking for a similar command line function to report system load as an integer or float.
You can try this at a windows command line. This works in XP, get a lot of other info too.
Don't use load...
The system load is not a good indicator in this case. On Unix it essentially tells you, how many processes are ready and waiting to be executed at the moment. But since there are numerous reasons for why a process might have to wait, your script may actually be able to run without costing another process any performance, even if the "load" on the system is high.
... use nice
You should use nice(1) on Unix and the equivalent on Windows ("Process Priority"?), so the OS can decide, when to run your script!
If you set the priority of your script to the absolute lowest possible priority then it will only be executed by the scheduler when there is nothing else to do at the moment.
Probably you will have to implement some kind of mechanism to prevent more than one instance of your script to be run at the same time, in case it takes longer to execute than the interval between to invocations lasts.