serial input _and_ time of day based tasks?

S

Stan Brown

I've got a script that reads from a serial port, and blocks on that.

Now I need to have it swap log files at midnight. I looked at Event.pm,
but it seemed a bit overkill, and I could not see how to make time of day
trigger it.

What other choices might I consider?
 
P

Peter Dintelmann

Hi,

Stan Brown said:
Now I need to have it swap log files at midnight. I looked at Event.pm,
but it seemed a bit overkill, and I could not see how to make time of day
trigger it.

What other choices might I consider?

have a look at setitimer() in the Time::HiRes module
which offers periodical SIGALRMs.

HTH,

Peter Dintelmann
 
T

Ted Zlatanov

I've got a script that reads from a serial port, and blocks on that.

Now I need to have it swap log files at midnight. I looked at
Event.pm, but it seemed a bit overkill, and I could not see how to
make time of day trigger it.

What other choices might I consider?

Have cron run a second script (doesn't have to be Perl, e.g. kill or
pkill will work) sending the primary script a USR1 signal at midnight.

The primary script can be detected by the name (Proc::processTable,
pkill) or by PID (write the PID to a file the secondary script will
open).

Then the primary script just has to catch a USR1 signal. Try not to
do anything involved in the signal handler, best to only set a global
$usr1caught variable and get out.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top