timer 3plumb 2012-09-07

NAME

timer - emit output and/or events with delay

SYNPOSIS

[timer period=SECONDS repeat=INT]

[timer period=SECONDS repeat=INT msg=TEXT events=BOOLEAN]

 
+-------+
| timer |----> (stdout) 1
+-------+
    |
    V
 (events)
    4

DESCRIPTION

Runs a timer in the background mutiple times (repeat) with a predefined delay (period) before each run. Delay is specified in seconds, and is a floating point number.

When the tick is generated, either msg or if msg is not specified the default timer info line is written on stdout (if it is not closed). If events is true, an event with the default timer info line is emitted.

The default timer info line is:

 
	plumb_timer %d %s\n

where %d is the timer counter (how many triggers remain) and %s is the msg.

NOTE: timer does not filter or alter msg - if it contains newlines, the emitted event will contain newlines that may fool some event processors. If msg is not empty and does not end with \n, the stream on stdout won't contain newlines either.

eof handling

Ignores eof. If there is an eof on stdout and the timer was configured to also emit events, it will keep on emiting events without writing the output.

blocking/flow control

Default.

buffering

None.

EXAMPLE

Print 4 of the default timer info lines, with delay of 0.1 seconds in between:
 
	[timer period=0.1 repeat=4],sticky=1 | env:1
Print hello world twice, with minimal delay in between:
 
	[timer period=0 repeat=2 msg="hello world!"],sticky=1 | env:1

SEE ALSO

timer 3plumb 2012-09-07