Introduction About Site Map

XML
RSS 2 Feed RSS 2 Feed
Navigation

Main Page | Blog Index

Wednesday, July 31st, 2013, 7:00 am

UNIX/Linux: Suspend and Resume Process in Intervals

HAVING spent over an hour searching the Web and asking around the Web for a way of automating suspension and continuation (SIGCONT and SIGINT) of process execution in GNU/Linux, I finally found a script from Q. Boiler, which I have modified a bit to make it simpler to use.

Sometimes the scheduler used in GNU/Linux systems is so resources-greedy that it will let a process take up all the CPU/core cycles and in some cases, as in mine, lead to overheat and system shutdown (my ventilation seems to be flawed or maybe to blame is the unusual summer weather here in the UK because this only ever happens in summer). Anyway, having struggled to find a way to nice a process sufficiently or send the process a universal system signal to help reduce its load on the system, I finally found something which can automate what I have been doing manually (CTRL+Z and fg), especially when rendering some Blender3D clips for my own use. Here is the simple script to be run:



#!/bin/bash
#    Based on a script from Q. Boiler (q.boiler@quantprinciple.com)


var0=0
LIMIT=20

PROCESSID=$1
SLEEP=30
RUN=10

pid=$PROCESSID

while [ "$var0" -lt "$LIMIT" ]
do



kill -SIGSTOP $pid
echo "Suspending $pid"

sleep $SLEEP

kill -SIGCONT $pid
echo "continuing execution $pid"

sleep $RUN

done
echo "killing $pid"
kill -SIGINT $pid


The way to use this is to save the above as a script, say script.sh, give it running permissions, e.g. chmod 755 script.sh, then call it with the process ID as the argument name, e.g. script.sh 46223. The intervals for running can be set within the script or with slight modifications be passed as arguments to the script (this is not crucial for my needs). In case someone else runs into the same problem I have decided to document this publicly.

Technical Notes About Comments

Comments may include corrections, additions, citations, expressions of consent or even disagreements. They should preferably remain on topic.

Moderation: All genuine comments will be added. If your comment does not appear immediately (a rarity), it awaits moderation as it contained a sensitive word or a URI.

Trackbacks: The URI to TrackBack this entry is:

https://schestowitz.com/Weblog/archives/2013/07/31/suspend-and-resume/trackback/

Syndication: RSS feed for comments on this post RSS 2

    See also: What are feeds?, Local Feeds

Comments format: Line and paragraph breaks are automatic, E-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Back to top

Retrieval statistics: 21 queries taking a total of 0.112 seconds • Please report low bandwidth using the feedback form
Original styles created by Ian Main (all acknowledgements) • PHP scripts and styles later modified by Roy Schestowitz • Help yourself to a GPL'd copy
|— Proudly powered by W o r d P r e s s — based on a heavily-hacked version 1.2.1 (Mingus) installation —|