Support Requests item #558351, was opened at 2002-05-20 13:14
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=203152&aid=558351&group_id=3152

Category: Configuration: First-Time Startup
Group: aolserver3_2
Status: Open
Resolution: None
Priority: 5
Submitted By: Paul Grady (paulgrady)
Assigned to: Nobody/Anonymous (nobody)
Summary: Using  ns_schedule_proc

Initial Comment:
I have a need to schedule TCL scripts to run at pre-
defined intervals. Ideally, I would like the server to
execute a single script once every hour. That script
could in turn execute other user definable scripts
when appropriate. I would like the process to start
when the server is started.

ns_schedule_proc sounds like it would be ideal for
this. My question is, how can I execute
ns_schedule_proc at startup. I tried to source the
procedure to be executed and place the
ns_schedule_proc in nsd.tcl. However the server had
not yet sourced the procedure to be executed and gave
me an error.

Any help would be greatly appreciated!

----------------------------------------------------------------------

Comment By: Peter M. Jansson (petej)
Date: 2002-05-20 13:30

Message:
Logged In: YES
user_id=20577

A common technique for doing this is to put the invocation of ns_schedule_proc in a 
tcl file named zz_init.tcl in your tcl module, because it usually sorts last, and 
will, thus, be the last-sourced tcl file.

You may find that it's better to schedule your procs as needed, rather than try to 
sub-schedule procs from one proc.  ns_schedule_proc on an interval may exhibit some 
drift around the interval, depending on how long the script takes to execute, so if 
you need something to run at 0400 every day, you're better off explicitly scheduling 
that, rather than running an hourly proc and trying to notice when it's 0400.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-05-20 13:25

Message:
Logged In: NO


---- mycode.tcl ----

proc my_hourly_proc {  } {
        #
        # do stuff here
        #
}

ns_share my_timer
if [info exists my_timer] {
        ns_unschedule_proc $my_timer
}
set my_timer [ns_schedule_proc -thread 3600 my_hourly_proc]

---- mycode.tcl ----

----------------------------------------------------------------------

You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=203152&aid=558351&group_id=3152

Reply via email to