[kwlug-disc] Clock-time limits

Khalid Baheyeldin kb at 2bits.com
Wed May 6 21:58:55 EDT 2009


On Wed, May 6, 2009 at 7:31 PM, Chris Irwin <chris at chrisirwin.ca> wrote:

> List, is there a way to limit the amount of clock-time a program is
> allowed to run?
>
> I currently use offlineimap via cron to cache my mail locally. It
> unfortunately seems to have a habit of becoming unresponsive if it
> happens to be active when I suspend/resume my laptop (probably the
> network disappearing). This then causes me to not (locally) receive any
> mail as when spawned by cron again it bails out due to the existing
> process.
>
> I could add 'pkill offlineimap' to the start of my wrapper script, but
> was hoping for something more elegant.
>

#!/bin/sh
yourprogram -options &
CMD_PID=$!
sleep 300
kill $CMD_PID

That should limit it to running for 300 seconds only.
-- 
Khalid M. Baheyeldin
2bits.com, Inc.
http://2bits.com
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra
Simplicity is the ultimate sophistication. --   Leonardo da Vinci
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20090506/5f602cec/attachment.htm>


More information about the kwlug-disc mailing list