Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Gracefully exiting and restarting at a later time.

by TJPride (Pilgrim)
on Dec 21, 2011 at 07:03 UTC ( [id://944546]=note: print w/replies, xml ) Need Help??


in reply to Gracefully exiting and restarting at a later time.

Well, you definitely don't want to die in the middle of a file - that'll make things too complicated - so you probably don't want to just kill and restart it. What you -could- do is check memory usage after each file and then exit if you've built up more than a certain percentage of memory usage. This works on my system:

use strict; use warnings; my ($data, $mem); my $kb = ' ' x 1024**2; do { $data .= $kb; $_ = `ps -p $$ -o %mem`; ($mem) = m/(\d+\.\d+)/; } while ($mem < 50);

You could also have it check for a file named a certain thing (like exit.txt) and exit if it sees that as well, deleting before exit so you're prepped for the next run.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://944546]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found