Forum OpenACS Development: Problems with ns_schedule_daily

Collapse
Posted by Victor John on
I am trying to use ns_schedule_daily to run a script
(i called "set id [ns_schedule_daily -thread 13 00 [ ns_log notice "scheduling a script" ] ])
It ran just after i start the schedule,not at 13:00 as expected. And never run the second day.

Does anyone knows why? or are there any other ways to schedule something daily?

Thanks a million!

Collapse
Posted by Don Baccus on
You're being caught by not properly understanding Tcl semantics.

Note the difference between your example and the Tcl manual example here:

set id [ns_schedule_daily -once 5 35 { ns_log notice "It is now 5:35 AM." }]
Commands enclosed in square brackets are executed immediately by the Tcl interpreter. So the "ns_log" command is actually executed BEFORE the call to ns_schedule_daily call. It appears to "not run the second day" because it's already been executed - the RESULT of "ns_log" (which is the empty string) is being executed every day which of course doesn't cause anything to show up in your output log.

In contrast, the example in the Tcl API document surrounds the ns_log in CURLY not SQUARE braces. This simply passes the list, unevaled, to ns_schedule_daily. So that list (ns_log Notice "scheduling a script"), rather than the result from EVALing it is then stored by ns_schedule and you get the results you expect.

Hope this helps you ... the semantics of quoting, square-bracketing, and curly-bracketing in the Tcl interpreter is crucial to understanding how things work. It's simple once you understand the rules, though.

Collapse
Posted by Brian Fenton on
Victor,
ns_info scheduled returns a list of lists of all the scheduled processes. If you get a copy of nstelemetry.adp you can see this data in a nicely formatted table.

Brian