Start and stop programs depending on the system load

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Manual Override

Sometimes, it's also necessary to manually access the mechanism triggered by loadwatch . For example, a program might not stop when loadwatch has been put it in sleep mode. In a situation like this, lw-ctr will help.

In order for loadwatch and lw-ctr to communicate, loadwatch will need to be invoked with the -u <Socket> option . Then, lw-ctr will send commands over this connection to loadwatch .

The simple lw-ctr program merely recognizes three commands and sends them on to loadwatch .

  • RUN : Starts the program controlled by loadwatch
  • STOP : Stops the program controlled by loadwatch
  • WATCH : Activates the standard mode in loadwatch , where the thresholds set for loadwatch are observed

The syntax for lw-ctr looks like the following:

lw-ctr Socket Command

For example, you can say: lw-ctr /tmp/tst.loadwatch RUN . You will always need to provide a socket.

A second application should briefly be described here. Programs like MediathekView are not easy to control remotely via the command line. Thus, if you want to do something with this program, such as record a live stream during an inconvenient broadcast time, you can proceed as follows.

Start the program via loadwatch with a threshold high enough to prevent interruptions. Now MediathekView will perform all of the required initializations. This will often take several minutes. After this step, you can select the Live Stream and start recording.

You can stop the recording process with lw-ctr … STOP . Next, you can use sleep … or better yet the at command to send a START command to the program at the desired time. The program will quickly execute this command.

Conclusion

Dale E Martin and later Nicolas Boullis thought up a mechanism that is quite similar and that works well in many cases. It is not always easy to find suitable parameters for the thresholds, so a graphical interface with a slider would be a good solution. Also, one feature is still lacking: lw-ctr cannot adapt the thresholds for loadwatch . This is too bad.

Of course, it is possible to manually do everything that loadwatch does using the signals STOP and CONT. This can be done directly via kill on the command line or by means of qps or similar tools invoked from a graphical interface. This manual method, however, requires a lot more work for the user. Altogether, the effort-to-benefit ratio for loadwatch is extremely good. You should take the time to experiment with this tool.

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content