jeroenes has asked for the wisdom of the Perl Monks concerning the following question:
The script wakes up (should wake up) every 5 minutes, go and retrieve traffic-jam info from a dutch site, log it, and when the time is right, it should report this info in an e-mail to my wife, who uses this info to determine the time of her homily return. As you can imagine, this script really is a part of our married life ;-).
The main loop is as follows:
and I use IO::Socket to retrieve the web-page. The script runs just fine, but after a couple of days it starts to eat CPU time so I have to kill the process.while (1){ @the_html=init_html(); @data=parse_data(@the_html); if (@data) { write_data(filter_data(@data)); mail_data(filter_data(@data)); } else { write_data("\tNo connection or data, so","\tsleeping until next fe +tch."); } sleep(300); }
Normally I ran it with exec get_files.pl files &, after which I killed the terminal. But lately I discovered that if I leave the terminal open, the script keeps running without a problem. At the moment it has been running for one week without a problem.
It runs, my wife is happy, and so am I. But, I still don't know why the script goes mad when I close the terminal. Is there a reason? Am I doing something wrong? I'm very curious about this.
If your (our?) great society of monks could come up with an answer, a humble novice would be made very happy.
May the Perl be with you,
Jeroen
PS: If any ofyou happen to live in Holland, and are interested in the script itself, don't hesitate to contact me.
|
---|