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 triggered every month?

Help for those learning Tcl or writing their own scripts.
Post Reply
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Bind time triggered every month?

Post by Fill »

Hi guys,

I was wondering how can I make a bind time that calls the script every month. E.g. if I wanted to execute it every minute, it would be:

Code: Select all

bind time - "00 * * * *" proc
But I want it every month, not every minute.. any ideas :?:

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

Post by arfer »

I am also interested in a competent reply to this question. Time masks seem to be something of an artform.

First off, in an earlier thread just a few days ago we have established that a very simple mask would yield every minute. As follows :-

Code: Select all

bind TIME - * procname
The way I would tackle the problem of once per month is to specify the minute/hour/day that I would like the bind to trigger, such as :-

Code: Select all

bind TIME - "20 10 15 * *" procname
I would take that to read .. at 10:20am on the 15th of every month of every year. Don't forget to choose a day that exists in all months.
I must have had nothing to do
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

Hi arfer,

Thanks for your reply - that was a good idea. I chose to make it like this:

Code: Select all

bind time - "00 00 28 * *" clear_records
That way it will run almost in the end of the month, except for february, which will run exactly in the end of the month. So my issue should be solved by now.

Aditionally, I'd like to know if there is really anyway to make our eggies know when a month finished, even if it's a month with 30 or 31, or if it's February. Just for curiosity ... my script doesn't need to run exactly in the end of every month, but now I'm curious about it :P

Once again, thanks for the fast and great reply.

See you arround,
Fill
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

It would be possible to write a Tcl script that runs recursively to test how close to the end of a particular month it is, using [unixtime] or [clock seconds] to get the local time and some form of [clock format] to derive the day and time of the month. Then trigger some action if it is within a preset timeframe prior to month end. Frankly, I think it would be a major waste of time and resource.
I must have had nothing to do
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Fill wrote:Hi arfer,

Thanks for your reply - that was a good idea. I chose to make it like this:

Code: Select all

bind time - "00 00 28 * *" clear_records
That way it will run almost in the end of the month, except for february, which will run exactly in the end of the month. So my issue should be solved by now.

Aditionally, I'd like to know if there is really anyway to make our eggies know when a month finished, even if it's a month with 30 or 31, or if it's February. Just for curiosity ... my script doesn't need to run exactly in the end of every month, but now I'm curious about it :P

Once again, thanks for the fast and great reply.

See you arround,
Fill
Why do you test for the end of the month before it has occured?

Code: Select all

bind time "00 00 01 * *" clear_records
You only really need to know at exactly which point when the old month has expired. The easiest way to do this is simply check against first day of every new month at exactly midnight. You bind to this event instead and it's easier and more accurate.
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

ahhhh, right, didn't even think about that!! lol.... thanks a lot for the reply. that will do it...

@ arfer:
Yeap, I agree that such script would give me a lot of unnecessary work.

Once again, thanks for your help.

See you
Post Reply