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.7 -r1.8 --- openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 1 Nov 2003 08:45:38 -0000 1.7 +++ openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 29 May 2009 09:02:11 -0000 1.8 @@ -1,7 +1,7 @@ ad_library { - Cronjog support procs + Cronjob support procs - @author Tom Jackson + @author Tom Jackson @creation-date 22 Sept 2001 @cvs-id $Id$ @@ -22,7 +22,7 @@ set dayofweek [ns_fmttime $time %w] 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 } } @@ -33,46 +33,47 @@ Proc to run cronjobs } { + # To avoid errors + set rownum 0 + + set table "No SQL" - ns_log Debug "cronjob_run: Cronjob_id is $cronjob_id" + ns_log Debug "Cronjob_id is $cronjob_id $rownum" db_1row cronjob_query {} 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" - } - } - append table "" - for {set i 0 } {$i < $size} {incr i} { - append table "\n" - } - append table "" - incr rownum - } - } - append table "
[ns_set key $sel $i]
[ns_set value $sel $i]
" - if {$rownum == 0} { - set table "No Rows Returned" - } - ns_db releasehandle $db + set rownum 0 + set table "" + db_foreach cronjob_run_sql $run_sql -column_set row { + + set size [ns_set size $row] + if {$rownum == 0} { + for {set i 0 } {$i < $size} {incr i} { + append table "\n" + } + } + append table "" + for {set i 0 } {$i < $size} {incr i} { + append table "\n" + } + append table "" + incr rownum + } } + append table "
[ns_set key $row $i]
[ns_set value $row $i]
" + if {$rownum == 0} { + set table "No Rows Returned" + } + # evaluate the run_tcl code eval $run_tcl if {![string match "" $email]} { - ns_log Debug "cronjob_run: 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 + ns_log Debug "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