Forum OpenACS Development: Re: Schedule a procedure to run on 1st of every month in project open.

Madhavi,

the solution i have pasted allows you to call an anytime foo maually. The function will be called as well every day, but the guard makes sure that the function body will be called only on the 1st of every month. Otherwise the function will return doing nothing.

Ok, last attempt: To make the behavior even more explicit, which one can use of many different functions should be called on every 1st:
define a function run_on_every_first and pass it an argument to a plain function (without guard):

proc -public run_on_every_first {proc args} {
    if {[clock format [clock seconds] -format "%e"] != 1} {
        # it is not the first, do nothing 
	return 
    }

    # use eval in case, proc has arguments
    eval $proc $args
}

# ... register which proc should be run on every 1st.
ad_schedule_proc -thread t -schedule_proc ns_schedule_daily [list 0 0] run_on_every_first YOUR_FUNCTION

Anyhow, if you have more complex needs (there are no indications from your postings), maybe the cronjob package can help you:
http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/cronjob