in reply to Re: automating a task
in thread automating a task

Ok, so this would suffice:

#shut off website... my $_sleepTime = (60 * 5); my $_notifyTime = time() + (60 * 60); my $_maxTime = time() + (60 * 60 * 6); until($dbh->selectrow_array(qq{select `value` from `pagevars` where `n +ame` = "eom_process"}) eq "ready") { $dbh->disconnect(); sleep($_sleepTime); $dbh = RWC::Sess::connect(); if(time() >= $_notifyTime) { # Send an email notifying of still not running... $_notifyTime = time() + (60 * 60);# Reset timer } if(time() >= $_maxTime) { # Send notice of final disconnection and exiting # to manually fix... send this notice to my cell # phone to alarm me # Disconnect from database.... if connected if($dbh) { $dbh->disconnect(); } exit; } }

that makes logical sense... so while it is sleeping it does not use any memory right? what if it does take all that time everytime it starts again does it keep building upon the memory it had and then get larger and larger? or does the disconnecting from the database reduce the memory on the fly, even before perl is exited?

thanks again,
Richard

Replies are listed 'Best First'.
Re^3: automating a task
by ww (Archbishop) on May 31, 2009 at 21:47 UTC

    ...so while it is sleeping it does not use any memory right?

    No, not right: it still reserves whatever memory it had allocated when the sleep starts at line 7 (which includes a small amount of memory required for the countdown tracking) -- and it still uses a few CPU cycles to do the tracking.

    what if it does take all that time everytime it starts again does it keep building upon the memory it had and then get larger and larger?

    There's no obvious (to me) reason for the memory useage to grow when the sleep time expires. However, you're disconnecting from the database before the sleep, so you'll need someone with a better handle on garbage collection and memory release to get a knowledgeable reply. Note, though, that "starts again" is perhaps better phrased "resumes." sleep does not force reinitialization of anything, except as forced to do so by your code.

    ...reduce the memory on the fly, even before perl is exited?

    Likewise, heed what wiser heads say about this, but my understanding is that that's not likely.