more useful options | |
PerlMonks |
cron-like timing within perl script?by n8ur (Acolyte) |
on Feb 28, 2004 at 19:01 UTC ( [id://332507]=perlquestion: print w/replies, xml ) | Need Help?? |
n8ur has asked for the wisdom of the Perl Monks concerning the following question:
Hi all --
I am trying to design a perl script that triggers data collection and logging every X seconds. The problem is that the collection process (reading data from an external instrument via a GPIB port) takes an imprecise amount of time; on a 60-second cycle, I can estimate the time the instrument will take to within two or three seconds, but not more closely than that.
So something as simple as:
doesn't cut it; my log entries won't be properly aligned because the data collection function may take a bit more or less than 55 seconds. What I want to do, I think, is along the lines of:
It seems like using the alarm function to trigger the reading process on receipt of SIGALRM should let me do this but I haven't figured out how to make it work reliably; in particular, I can't figure out what kind of loop structure I need to keep the program alive. I'd sure appreciate any help on how to implement a "sleep until alarm" capability in my program. Thanks!
Back to
Seekers of Perl Wisdom
|
|