This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

bind time , with multiple values

Help for those learning Tcl or writing their own scripts.
Post Reply
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

bind time , with multiple values

Post by willyw »

Hello,

Does bind time accept values the same way as crontab does?


Here's what I'm doing:
I have a small script I drew up, and it uses :
bind time - "01 * * * *" do_announce
just fine. The procedure does an announcement in a channel, once per hour.

I'd like to experiment with making that once every other hour.
And other variations too.
Perhaps once every 3 or 4 hours.
Whatever... until I get it like I like it.

And I wondered if I could use entries like I found here:
http://ss64.com/bash/crontab.html
Would it be?:
bind time - "* 01,03,05,07,09,11,13,15,17,19,21,23 * * *" do_announce

If not, ...if bind time does not accept that, how would I go about it?


Thanks
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The time binding simply does a glob-style matching of a fixed string being 'minute hour day-of-month month year' (of the curent time) against the mask provided in the binding. As such, you cannot use the more advanced syntax of crontab's.

You could, however, do additional checks on the hour within the triggered code. Ie: for every n:th hour, use the modulus function or so..
NML_375
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

nml375 wrote:The time binding simply does a glob-style matching of a fixed string being 'minute hour day-of-month month year' (of the curent time) against the mask provided in the binding. As such, you cannot use the more advanced syntax of crontab's.
Thanks.

Another idea came to mind.
What would happen if I simply created more binds?
as in:
bind time - "0 01 * * *" do_announce
bind time - "0 03 * * *" do_announce
bind time - "0 05 * * *" do_announce
.
.
.
and so on.


Would that do it?
Would the do_annouce procedure run at 1:00am, 3:00am, 5:00am, and so on?

You could, however, do additional checks on the hour within the triggered code. Ie: for every n:th hour, use the modulus function or so..
I don't get it, yet.
Can you elaborate a bit?


Thanks
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The following code executes at minute 00 for every 'ODD' hour by testing if the number of hours has a remainder after dividing by 2 (hour mod 2). The result can only be 1 (true) or 0 (false)

Code: Select all

bind TIME - "00 * * * *" pTimeProc

proc pTimeProc {minute hour day month year} {
  if {$hour % 2} {
    # code here
  }
}
I must have had nothing to do
Post Reply