Index: openacs-4/packages/cronjob/tcl/cronjob-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/tcl/cronjob-procs.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 12 Sep 2002 22:44:25 -0000 1.4
+++ openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 30 Nov 2002 17:29:40 -0000 1.5
@@ -13,33 +13,18 @@
} {
- # setup the vars
- set time [ns_time]
- set minute [ns_fmttime $time %M]
- set hr [ns_fmttime $time %H]
- set mon [ns_fmttime $time %m]
+ # setup the vars
+ set time [ns_time]
+ set minute [ns_fmttime $time %M]
+ set hr [ns_fmttime $time %H]
+ set mon [ns_fmttime $time %m]
set day [ns_fmttime $time %d]
set dayofweek [ns_fmttime $time %w]
- set sql "
-select
- cronjob_id
-from
- cronjobs
-where
- disabled_p = 'f' AND
- approved_p = 't' AND
- ((minute = :minute) OR (minute = '*')) AND
- ((hr = :hr ) OR (hr = '*')) AND
- ((mon = :mon ) OR (mon = '*')) AND
- ((day = :day ) OR (day = '*')) AND
- ((dayofweek = :dayofweek ) OR (dayofweek = '*'))"
-
- db_foreach cronjob_sched_foreach $sql {
+ db_foreach cronjob_sched_foreach "" {
+ ad_schedule_proc -once t -thread t 1 cronjob_run $cronjob_id
+ }
- ad_schedule_proc -once t -thread t 1 cronjob_run $cronjob_id
- }
-
}
@@ -48,57 +33,47 @@
Proc to run cronjobs
} {
- set table "No SQL"
- set sql "
-select
- description,
- run_sql,
- run_tcl,
- email
-from
- cronjobs
-where
- cronjob_id = :cronjob_id"
- ns_log Notice "Cronjob_id is $cronjob_id"
- db_1row "crontab_query" $sql
- db_release_unused_handles
- if {![string match "" $run_sql]} {
- set table "
"
- set db [ns_db gethandle "log"]
- set sel [ns_db select $db $run_sql]
- set rownum 0
- if {![string match "" $sel]} {
- while {[ns_db getrow $db $sel]} {
- set size [ns_set size $sel]
- if {$rownum == 0} {
- for {set i 0 } {$i < $size} {incr i} {
- append table "\n[ns_set key $sel $i] | "
- }
- }
- append table ""
- for {set i 0 } {$i < $size} {incr i} {
- append table "\n[ns_set value $sel $i] | "
- }
- append table "
"
- incr rownum
- }
- }
- append table "
"
- if {$rownum == 0} {
- set table "No Rows Returned"
- }
- ns_db releasehandle $db
+ set table "No SQL"
+ ns_log Notice "Cronjob_id is $cronjob_id"
+ db_1row crontab_query $sql
+ db_release_unused_handles
+ if {![string match "" $run_sql]} {
+ set table ""
+ set db [ns_db gethandle "log"]
+ set sel [ns_db select $db $run_sql]
+ set rownum 0
+ if {![string match "" $sel]} {
+ while {[ns_db getrow $db $sel]} {
+ set size [ns_set size $sel]
+ if {$rownum == 0} {
+ for {set i 0 } {$i < $size} {incr i} {
+ append table "\n[ns_set key $sel $i] | "
+ }
}
+ append table ""
+ for {set i 0 } {$i < $size} {incr i} {
+ append table "\n[ns_set value $sel $i] | "
+ }
+ append table "
"
+ incr rownum
+ }
+ }
+ append table "
"
+ if {$rownum == 0} {
+ set table "No Rows Returned"
+ }
+ ns_db releasehandle $db
+ }
- # evaluate the run_tcl code
- eval $run_tcl
+ # evaluate the run_tcl code
+ eval $run_tcl
- if {![string match "" $email]} {
- ns_log notice "sending cronjob email to $email"
- set headers [ns_set create]
- ns_set put $headers "Content-Type" "text/html"
- ns_sendmail $email [ad_host_administrator] "Cronjob $cronjob_id" "Description:
$description
$table" $headers
- }
- return
+ if {![string match "" $email]} {
+ ns_log notice "sending cronjob email to $email"
+ set headers [ns_set create]
+ ns_set put $headers "Content-Type" "text/html"
+ ns_sendmail $email [ad_host_administrator] "Cronjob $cronjob_id" "Description:
$description
$table" $headers
+ }
+ return
}