Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9354)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9355)
@@ -18,4 +18,27 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2009/02/10 Daniela Dorner
+
+   * datacenter/scripts/buildsequenceentries, 
+     datacenter/scripts/checkfilesforsequenceavail, 
+     datacenter/scripts/checkstardone, datacenter/scripts/correcttime,
+     datacenter/scripts/dbchk, datacenter/scripts/dodatacheck,
+     datacenter/scripts/doexclusions, datacenter/scripts/fillcallisto, 
+     datacenter/scripts/fillcamera, datacenter/scripts/fillganymed, 
+     datacenter/scripts/fillstar, datacenter/scripts/insertdatasets, 
+     datacenter/scripts/makecallistolinks, 
+     datacenter/scripts/mcsequences, datacenter/scripts/movingrawfiles, 
+     datacenter/scripts/movingrawfiles_OK, datacenter/scripts/runcamera,
+     datacenter/scripts/runcorsika, datacenter/scripts/runreflector,
+     datacenter/scripts/sourcefile, 
+     datacenter/scripts/writedatasetfiles, 
+     datacenter/scripts/writesequencefiles:
+     - removed scriptlog
+
+   * datacenter/scripts/jobmanager: 
+     - fixed typo
+
+
+
  2009/02/19 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -58,18 +55,16 @@
    date=${primaries[$s+$s]}
    telnum=${primaries[$s+$s+1]}
-   echo "building sequence entries for date $date..." >> $scriptlog 2>&1
    printprocesslog "INFO build sequence entries for $date"
    year2=`echo $date | cut -c 1-4`
    buildsequentriespath=$logpath/$program/$year2
-   makedir  $buildsequentriespath >> $scriptlog 2>&1
+   makedir  $buildsequentriespath 
    buildsequentrieslog=$buildsequentriespath/buildsequenceentries-$date.log
 
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
    check1=`root -q -b $macrospath/buildsequenceentries.C+\("\"$date\""\,"\"$datapath\""\,"\"$sequpath\""\,$telnum\,kFALSE\) | tee $buildsequentrieslog | intgrep`
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok -> setting status for $date..." >> $scriptlog 2>&1
-           printprocesslog "INFO sequence entries successfully built for $date"
+      1)   printprocesslog "INFO sequence entries successfully built for $date (check1=$check1)"
            IFS=$'\n'
            missing=( `grep "Missing" $buildsequentrieslog` )
@@ -83,10 +78,8 @@
            unset IFS
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check1=$check1 -> ERROR - $program.C failed for $date -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR $program.C failed for $date"
+      *)   printprocesslog "ERROR $program.C failed for $date (check1=$check1)"
            com=$Fbuildsequ
            check=$check1
@@ -94,7 +87,7 @@
    esac
 
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -58,30 +55,25 @@
    sequence=${primaries[$s+$s]}
    telnum=${primaries[$s+$s+1]}
-   echo "checking files for sequence $sequence..." >> $scriptlog 2>&1 
    printprocesslog "INFO checking files for sequence $sequence"
    no=`printf %08d $sequence | cut -c 0-4`
    no2=`printf %08d $sequence`
    checkfileavailpath=$logpath/$program/$no
-   makedir $checkfileavailpath  >> $scriptlog 2>&1 
+   makedir $checkfileavailpath 
    checkfileavaillog=$checkfileavailpath/$program-$no2.log
 
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
    check1=`root -q -b $macrospath/checkfileavail.C+\($sequence,$telnum\) | tee $checkfileavaillog | intgrep`
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1 
-           printprocesslog "INFO files available for sequence $sequence"
+      1)   printprocesslog "INFO files available for sequence $sequence (check1=$check1)"
            ;;
-      2)   echo " check1=$check1 -> files not yet available -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "INFO files not yet available for sequence $sequence"
+      2)   printprocesslog "INFO files not yet available for sequence $sequence (check1=$check1)"
            check="no"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR $program.C failed for sequence $sequence"
+      *)   printprocesslog "ERROR $program.C failed for sequence $sequence (check1=$check1)"
            com=$Ffilesavail
            check=$check1
@@ -89,7 +81,7 @@
    esac
 
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkstardone
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 9355)
@@ -40,13 +40,10 @@
 column=fStarFilesAvail
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -55,26 +52,22 @@
 do
    dataset=${primaries[$s]}
-   echo "checking star done for sequences of dataset $dataset..." >> $scriptlog 2>&1 
    printprocesslog "INFO checking star done for sequences of dataset $dataset"
 
    outpath=$logpath/$program/`printf %08d $dataset | cut -c 0-5`
-   makedir $outpath  >> $scriptlog 2>&1 
+   makedir $outpath 
 
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
    check1=`root -q -b $macrospath/checkstardone.C+\($dataset\) | tee $outpath/checkstardone-$dataset.log | intgrep`
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok -> continue with next dataset..." >> $scriptlog 2>&1 ;;
-      2)   echo " check1=$check1 -> star files for dataset $dataset not yet available -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "INFO files not yet available for dataset $dataset"
+      1)   printprocesslog "INFO check1=$check1 -> everything ok -> continue with next dataset..." 
+      2)   printprocesslog "INFO files not yet available for dataset $dataset (check1=$check1)"
            check="no"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check1=$check1 -> ERROR checkstardone.C failed for dataset $dataset" >> $scriptlog 2>&1 
-           printprocesslog "ERROR checkstardone.C failed for dataset $dataset"
+      *)   printprocesslog "ERROR checkstardone.C failed for dataset $dataset (check1=$check1)"
            com=$Fstardone
            check=$check1
@@ -82,6 +75,6 @@
    esac
 
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
Index: trunk/MagicSoft/Mars/datacenter/scripts/correcttime
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 9355)
@@ -39,5 +39,5 @@
 source `dirname $0`/sourcefile
 printprocesslog "INFO starting $0"
-echo "This script has not been adapted to the new file structure (MAGIC II). "
+echo "This script has not been adapted to the new file structure (MAGIC II) and new logging. "
 echo "Please adapt it before using it."
 exit
Index: trunk/MagicSoft/Mars/datacenter/scripts/dbchk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9355)
@@ -46,53 +46,46 @@
 program=dbchk
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 getdbsetup
 alias mymysql='mysql -s -u $us --password=$pw --host=$ho $db'
 
 # check for crashed nights, runs, sequences and datasets
-echo "Checking if something is crashed on nightly basis" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if something is crashed on nightly basis" 
 nights=`echo "SELECT fDate FROM SequenceBuildStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql`
 if [ ! "$nights" = "" ]
 then
    printprocesslog "WARN For the following nights something seems to be crashed. Please check manually: $nights"
-   echo "WARN For the following nights something  seems to be crashed. Please check manually: $nights" >> $scriptlog 2>&1
 else
-   echo " Nothing found." >> $scriptlog 2>&1
+   printprocesslog "INFO Nothing found." 
 fi
 
-echo "Checking if something is crashed on run basis" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if something is crashed on run basis" 
 cruns=`echo "SELECT fRunNumber FROM RunProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql`
 if [ ! "$cruns" = "" ]
 then
    printprocesslog "WARN The following runs seem to be crashed. Please check manually: $cruns"
-   echo "WARN The following runs seem to be crashed. Please check manually: $cruns" >> $scriptlog 2>&1
 else
-   echo " Nothing found." >> $scriptlog 2>&1
+   printprocesslog "INFO Nothing found." 
 fi
 
-echo "Checking if something is crashed on sequence basis" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if something is crashed on sequence basis" 
 csequences=`echo "SELECT fSequenceFirst FROM SequenceProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()" | mymysql`
 if [ ! "$csequences" = "" ]
 then
    printprocesslog "WARN The following sequences seem to be crashed. Please check manually: $csequences"
-   echo "WARN The following sequences seem to be crashed. Please check manually: $csequences" >> $scriptlog 2>&1
 else
-   echo " Nothing found." >> $scriptlog 2>&1
+   printprocesslog "INFO Nothing found." 
 fi
 
-echo "Checking if something is crashed on dataset basis" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if something is crashed on dataset basis" 
 cdatasets=`echo "SELECT fDataSetNumber FROM DataSetProcessStatus WHERE isnull(fFailedTime) and not isnull(fStartTime) and adddate(fStartTime, Interval 12 HOUR) < Now()"  | mymysql`
 if [ ! "$cdatasets" = "" ]
 then
    printprocesslog "WARN The following datasets seem to be crashed. Please check manually: $cdatasets"
-   echo "WARN The following datasets seem to be crashed. Please check manually: $cdatasets" >> $scriptlog 2>&1
 else
-   echo " Nothing found." >> $scriptlog 2>&1
+   printprocesslog "INFO Nothing found." 
 fi
 
 # CHECK 1
-echo "Checking if all sequence files have a corresponding entry in Sequences" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequence files have a corresponding entry in Sequences" 
 files=`find $sequpath -type f`
 for file in $files
@@ -101,5 +94,4 @@
    if [ "$sequence" = "" ] || [ "$sequence" = "$file" ]
    then
-      echo "No sequence file: $file" >> $scriptlog 2>&1
       printprocesslog "ERROR No sequence file: $file" 
       continue
@@ -109,5 +101,4 @@
    if ! [ "$sequence" = "$var" ]
    then
-      echo "Sequence-File $sequence exist but it is not in Sequences." >> $scriptlog 2>&1
       printprocesslog "ERROR Sequence-File $sequence exists, but it is not in Sequences (DB)." 
       continue
@@ -116,5 +107,5 @@
 
 # CHECK 1b (callisto)
-echo "Checking if all sequences in ${datapath}/callisto have a corresponding sequence in Sequence" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences in ${datapath}/callisto have a corresponding sequence in Sequence" 
 dirs=`find ${datapath}/callisto -mindepth 2 -maxdepth 2 -type d`
 for dir in $dirs
@@ -123,5 +114,4 @@
    if [ "$sequence" = "" ] || [ "$sequence" = "$dir" ]
    then
-      echo "Invalid directory: $dir" >> $scriptlog 2>&1
       printprocesslog "ERROR Invalid directory: $dir" 
       continue
@@ -131,5 +121,4 @@
    if ! [ "$sequence" = "$var" ]
    then
-      echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1
       printprocesslog "ERROR $dir exists, but no corresponding sequence in Sequences (DB)." 
       continue
@@ -138,5 +127,5 @@
 
 # CHECK 1c (star)
-echo "Checking if all sequences in ${datapath}/star have a corresponding sequence in Sequence" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences in ${datapath}/star have a corresponding sequence in Sequence" 
 dirs=`find ${datapath}/star -mindepth 2 -type d`
 for dir in $dirs
@@ -145,5 +134,4 @@
    if [ "$sequence" = "" ] || [ "$sequence" = "$dir" ]
    then
-      echo "Invalid directory: $dir" >> $scriptlog 2>&1
       printprocesslog "ERROR Invalid directory: $dir" 
       continue
@@ -153,5 +141,4 @@
    if ! [ "$sequence" = "$var" ]
    then
-      echo "$dir exists but no corresponding sequence in Sequences." >> $scriptlog 2>&1
       printprocesslog "ERROR $dir exists, but no corresponding sequence in Sequences (DB)." 
       continue
@@ -160,5 +147,5 @@
 
 # CHECK 2
-echo "Checking if all sequences in Sequences have a corresponding sequence files" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences in Sequences have a corresponding sequence files" 
 sequences=`echo SELECT fSequenceFirst FROM Sequences left join SequenceProcessStatus using (fSequenceFirst,fTelescopeNumber) where not isnull(fSequenceFileWritten) | mymysql`
 for sequence in $sequences
@@ -167,5 +154,4 @@
    if [ "$var" = "" ]
    then
-      echo "Sequence-File for $sequence not found but in db." >> $scriptlog 2>&1
       printprocesslog "ERROR Sequence-File for $sequence not found but in DB." 
    fi
@@ -173,5 +159,5 @@
 
 # CHECK 3
-echo "Checking if all sequences from Sequences exist RunData" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences from Sequences exist RunData" 
 sequences=`echo SELECT fSequenceFirst FROM Sequences GROUP BY fSequenceFirst | mymysql`
 for sequence in $sequences
@@ -180,6 +166,5 @@
    if ! [ "$sequence" = "$res" ]
    then
-      echo "Sequence $sequence exists in Sequences but not in RunData." >> $scriptlog 2>&1
-      printprocesslog "Sequence $sequence exists in Sequences but not in RunData (DB)."
+      printprocesslog "ERROR Sequence $sequence exists in Sequences but not in RunData (DB)."
       continue
    fi
@@ -187,5 +172,5 @@
 
 # CHECK 4
-echo "Checking if all sequences from RunData exist in Sequences" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences from RunData exist in Sequences" 
 sequences=`echo SELECT fSequenceFirst FROM RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
 for sequence in $sequences
@@ -194,6 +179,5 @@
    if ! [ "$sequence" = "$var" ]
    then
-      echo "Sequence $sequence exists in RunData but not in Sequences." >> $scriptlog 2>&1
-      printprocesslog "Sequence $sequence exists in RunData but not in Sequences (DB)." 
+      printprocesslog "ERROR Sequence $sequence exists in RunData but not in Sequences (DB)." 
       continue
    fi
@@ -201,5 +185,5 @@
 
 # CHECK 5
-echo "Checking if all sequences from RunData exist in SequenceProcessStatus" >> $scriptlog 2>&1
+printprocesslog "INFO Checking if all sequences from RunData exist in SequenceProcessStatus" 
 sequences=`echo SELECT fSequenceFirst FROM RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
 for sequence in $sequences
@@ -208,9 +192,8 @@
    if ! [ "$sequence" = "$var" ]
    then
-      echo "Sequence $sequence exists in RunData but not in SequenceProcessStatus." >> $scriptlog 2>&1
-      printprocesslog "Sequence $sequence exists in RunData but not in SequenceProcessStatus (DB)." 
+      printprocesslog "ERROR Sequence $sequence exists in RunData but not in SequenceProcessStatus (DB)." 
       continue
    fi
 done
 
-finish >> $scriptlog 2>&1
+finish 
Index: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 9355)
@@ -41,5 +41,5 @@
 source `dirname $0`/sourcefile
 printprocesslog "INFO starting $0"
-echo "This script has not been adapted to the new file structure (MAGIC II). "
+echo "This script has not been adapted to the new file structure (MAGIC II) and new logging. "
 echo "Only the usage of getodo has been adapted, but not tested."
 echo "Please adapt it before using it."
Index: trunk/MagicSoft/Mars/datacenter/scripts/doexclusions
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if the script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -59,25 +56,21 @@
    date=${primaries[$s+$s]}
    telnum=${primaries[$s+$s+1]}
-   echo "do exclusions for date "$date >> $scriptlog 2>&1
-   printprocesslog "INFO do exclusions for $date"
+   printprocesslog "INFO do exclusions for $date $date"
    year2=`echo $date | cut -c 1-4`
    doexclusionspath=$logpath/$program/$year2
-   makedir $doexclusionspath >> $scriptlog 2>&1
+   makedir $doexclusionspath 
    doexclusionslog=$doexclusionspath/doexclusions-$date.log
 
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
    check1=`root -q -b $macrospath/doexclusions.C+\("\"$date\""\,$telnum\,kFALSE\) | tee $doexclusionslog | intgrep`
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1 
-           printprocesslog "INFO exclusions successfully done for $date"
+      1)   printprocesslog "INFO exclusions successfully done for $date (check1=$check1)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 
-           printprocesslog "ERROR $program.C failed"
+      *)   printprocesslog "ERROR $program.C failed (check1=$check1)"
            com=$Fdoexcl
            check=$check1
@@ -85,7 +78,7 @@
    esac
    
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(revision 9355)
@@ -43,13 +43,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if the script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo file
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -67,11 +64,10 @@
    calibfile=$path/calib$no2.root
    fillcallistologpath=$logpath/$program/$no
-   makedir $fillcallistologpath >> $scriptlog 2>&1
+   makedir $fillcallistologpath 
    fillcaliblog=$fillcallistologpath/fillcalib-$sequence.log
    fillsignallog=$fillcallistologpath/fillsignal-$sequence.log
 
-   echo "run $program for sequence $sequence" >> $scriptlog 2>&1
-   setstatus "start" >> $scriptlog 2>&1
-   echo "run fillcalib..." >> $scriptlog 2>&1
+   printprocesslog "INFO run $program for sequence $sequence" 
+   setstatus "start" 
    printprocesslog "INFO starting fillcalib for sequence $sequence"
 
@@ -79,17 +75,14 @@
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok -> run fillsignal " >> $scriptlog 2>&1 
-           printprocesslog "INFO done fillcalib successfully for sequence $sequence"
+      1)   printprocesslog "INFO done fillcalib successfully for sequence $sequence (check1=$check1)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
-           setstatus "stop" >> $scriptlog 2>&1
+           setstatus "stop" 
            continue ;;
-      *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR fillcalib failed for sequence $sequence"
+      *)   printprocesslog "ERROR fillcalib failed for sequence $sequence (check1=$check1)"
            com=$Ffillcalib
            check=$check1
-           setstatus "stop" >> $scriptlog 2>&1
+           setstatus "stop" 
            continue ;;
    esac
@@ -98,13 +91,10 @@
    check2=`root -q -b $macrospath/fillsignal.C+\("\"$signalfile\""\,kFALSE\) | tee $fillsignallog | intgrep`
    case $check2 in
-      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO done fillsignal successfully for sequence $sequence"
+      1)   printprocesslog "INFO done fillsignal successfully for sequence $sequence (check2=$check2)"
            ;;
-      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check2=$check2)"
            check="no"
            ;;
-      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR fillsignal failed for sequence $sequence"
+      *)   printprocesslog "ERROR fillsignal failed for sequence $sequence (check2=$check2)"
            com=$Ffillsignal
            check=$check2
@@ -112,7 +102,7 @@
    esac
    
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillcamera
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillcamera	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillcamera	(revision 9355)
@@ -1,3 +1,3 @@
-#!/bin/sh
+	#!/bin/sh
 #
 # ========================================================================
@@ -35,10 +35,7 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 getdbsetup
@@ -48,6 +45,5 @@
 #workaround
 cameradirs=`find /magic/montecarlo/camera -maxdepth 4 -mindepth 2 -type d ! -name Gamma ! -name Muon ! -name Proton ! -name Spot_?.?`
-echo "camera dirs: "${cameradirs[@]}  >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
+printprocesslog "INFO camera dirs: "${cameradirs[@]} 
 
 cd $mars
@@ -66,7 +62,7 @@
    fi
    epo=`echo $cameradir | cut -d/ -f5` #epoch
-   echo "dir: "$cameradir >> $scriptlog 2>&1
+   printprocesslog "INFO dir: "$cameradir 
    fillcamerapath=$logpath/$program
-   makedir $fillcamerapath >> $scriptlog 2>&1
+   makedir $fillcamerapath 
    fillcameralog=$fillcamerapath/$program-$epo-$par-$spot-$cam.log
    
@@ -74,22 +70,18 @@
 #   check0=`root -q -b $macrospath/fillcamera.C+\("\"$cameradir\""\,kTRUE\) | tee $fillcameralog | intgrep`
    case $check0 in 
-      1)   echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO fillcamera run successfully for dir $cameradir"
+      1)   printprocesslog "INFO fillcamera run successfully for dir $cameradir (check0=$check0)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check0=$check0)"
            check="no"
            ;;
-      *)   echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 
-           printprocesslog "ERROR $program.C failed for dir $cameradir"
+      *)   printprocesslog "ERROR $program.C failed for dir $cameradir (check0=$check0)"
            ;;
    esac
    
    printprocesslog "INFO linking cal and ped files"
-   echo "linking cal and ped files" >> $scriptlog 2>&1
    
    if [ $cam = "Cal_and_Ped" ];
    then
-      echo "Cal_and_Ped folder, no cal and ped files will be linked" >> $scriptlog 2>&1
+      printprocesslog "INFO Cal_and_Ped folder, no cal and ped files will be linked" 
    else
 
@@ -99,6 +91,6 @@
       calfile=`find $mccampath/$epo/Cal_and_Ped -name *_C_*.root`
    
-      echo "calfile for epoch $epo : " $calfile >> $scriptlog 2>&1
-      echo "pedfile for epoch $epo : " $pedfile >> $scriptlog 2>&1
+      printprocesslog "INFO calfile for epoch $epo : " $calfile 
+      printprocesslog "INFO pedfile for epoch $epo : " $pedfile 
    
       #check number of files
@@ -107,9 +99,6 @@
       if [ "$numfiles" != "2" ]
       then
-      	echo "too many or too less files in the directory $epo/Cal_and_Ped -> exit" >> $scriptlog 2>&1
-        rm -v $lockfile >> $scriptlog 2>&1
-   	exit
-      	printprocesslog "ERROR too many ped and cal files found in $epo/Cal_and_Ped"
-      	finish >> $scriptlog 2>&1
+      	printprocesslog "ERROR too many or too less ped and cal files found in $epo/Cal_and_Ped"
+      	finish 
       fi
       
@@ -122,6 +111,6 @@
       cnum=`printf %08d $crun`
       pnum=`printf %08d $prun`
-      echo "calrun number: " $cnum >> $scriptlog 2>&1
-      echo "pedrun number: " $pnum >> $scriptlog 2>&1
+      printprocesslog "INFO calrun number: " $cnum 
+      printprocesslog "INFO pedrun number: " $pnum 
       #get all directories in the linked structure for the epoch
       #dirs=`find $mcrawpath/ -mindepth 3 -maxdepth 3 -type d`
@@ -142,10 +131,10 @@
          if ls $dir | grep MonteCarlo | grep $pnum
          then 
-            echo "P run already there, do mysql update" >> $scriptlog 2>&1
+            printprocesslog "INFO P run already there, do mysql update" 
    #         continue
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $pupdate "
          else 
-            echo "linking P run for epoch $epo" >> $scriptlog 2>&1
-            ln -sv $pedfile $newpedfile >> $scriptlog 2>&1
+            printprocesslog "INFO linking P run for epoch $epo" 
+            ln -sv $pedfile $newpedfile 
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $pupdate "
          fi
@@ -153,10 +142,10 @@
          if ls $dir | grep MonteCarlo | grep $cnum
          then 
-            echo "C run already there, do mysql update" >> $scriptlog 2>&1
+            printprocesslog "INFO C run already there, do mysql update" 
    #         continue
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $cupdate "
          else 
-            echo "linking C run for epoch $epo" >> $scriptlog 2>&1
-            ln -sv $calfile $newcalfile >> $scriptlog 2>&1
+            printprocesslog "INFO linking C run for epoch $epo" 
+            ln -sv $calfile $newcalfile 
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $cupdate "
          fi
@@ -211,4 +200,4 @@
 
 
-finish >> $scriptlog 2>&1
-
+finish 
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -64,21 +61,18 @@
    ganymedfile=$path/ganymed$no2.root
    fillganymedlogpath=$logpath/$program/$no
-   makedir $fillganymedlogpath >> $scriptlog 2>&1
+   makedir $fillganymedlogpath 
    fillganymedlog=$fillganymedlogpath/$program-$dataset.log
 
-   echo "run $program for dataset $dataset" >> $scriptlog 2>&1
-   setstatus "start" >> $scriptlog 2>&1
+   printprocesslog "INFO run $program for dataset $dataset" 
+   setstatus "start" 
 
    check2=`root -q -b $macrospath/fillganymed.C+\("\"$ganymedfile\""\,kFALSE\) | tee $fillganymedlog | intgrep`
    case $check2 in
-      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO done fillganymed successfully for dataset $dataset"
+      1)   printprocesslog "INFO done fillganymed successfully for dataset $dataset (check2=$check2)"
            ;;
-      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check2=$check2)"
            check="no"
            ;;
-      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR fillganymed failed for dataset $datset"
+      *)   printprocesslog "ERROR fillganymed failed for dataset $datset (check2=$check2)"
            com=$Ffillganymed
            check=$check2
@@ -86,7 +80,7 @@
    esac
 
-   setstatus "stop" >> scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if the script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -65,21 +62,17 @@
    starfile=$path/star$no2.root
    fillstarlogpath=$logpath/$program/$no
-   makedir $fillstarlogpath >> $scriptlog 2>&1
+   makedir $fillstarlogpath 
    fillstarlog=$fillstarlogpath/$program-$sequence.log
 
-   echo "run $program for sequence $sequence" >> $scriptlog 2>&1
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
    check2=`root -q -b $macrospath/fillstar.C+\("\"$starfile\""\,kFALSE\) | tee $fillstarlog | intgrep`
    case $check2 in
-      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO done fillstar successfully for sequence $sequence"
+      1)   printprocesslog "INFO done fillstar successfully for sequence $sequence (check2=$check2)"
            ;;
-      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check2=$check2)"
            check="no"
            ;;
-      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR fillstar failed for sequence $sequence"
+      *)   printprocesslog "ERROR fillstar failed for sequence $sequence (check2=$check2)"
            com=$Ffillstar
            check=$check2
@@ -87,7 +80,7 @@
    esac
    
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 9355)
@@ -38,15 +38,11 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get all datasetfiles
 datasetfiles=(`ls $datasetpath/*/*.txt`)
-echo "datasetfiles: "${datasetfiles[@]}  >> $scriptlog 2>&1 
-echo "" >> $scriptlog 2>&1 
+printprocesslog "INFO datasetfiles: "${datasetfiles[@]} 
 
 cd $mars
@@ -66,31 +62,23 @@
    if [ "$no" = "$no3" ]
    then 
-      echo "number in filename and in file are the same -> continue" >> $scriptlog 2>&1 
+      printprocesslog "INFO number in filename and in file are the same -> continue" 
    else
-      echo "number in filename and in file are not the same " >> $scriptlog 2>&1 
-      echo " -> continue with next dataset" >> $scriptlog 2>&1 
       printprocesslog "ERROR number in filename ($no) and file ($no3) are not the same for dataset $no2"
       continue
    fi
    # get source name, comment and observation mode from dataset file
-   source=`grep 'SourceName:' $datasetfile | sed -e 's/SourceName://g' | sed -e 's/ //g' | sed -e 's/#//g'` >> $scriptlog 2>&1 
-   comment=`grep 'Comment:' $datasetfile | sed -e 's/Comment://g'` >> $scriptlog 2>&1 
-   mode=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1 
-   mode2=`echo $mode | grep ^\#` >> $scriptlog 2>&1 
+   source=`grep 'SourceName:' $datasetfile | sed -e 's/SourceName://g' | sed -e 's/ //g' | sed -e 's/#//g'` 
+   comment=`grep 'Comment:' $datasetfile | sed -e 's/Comment://g'` 
+   mode=`grep 'WobbleMode:' $datasetfile` 
+   mode2=`echo $mode | grep ^\#` 
    if [ "$mode2" = "" ]
    then 
-      wobble="Y" >> $scriptlog 2>&1 
+      wobble="Y" 
    else
-      wobble="N" >> $scriptlog 2>&1 
+      wobble="N" 
    fi
-   echo "file: "$datasetfile >> $scriptlog 2>&1 
-   echo "  datasetno:  "$no2 >> $scriptlog 2>&1 
-   echo "  sourcename: "$source >> $scriptlog 2>&1 
-   echo "  wobble:     "$wobble >> $scriptlog 2>&1 
-   echo "  comment:    "$comment >> $scriptlog 2>&1 
-   echo " " >> $scriptlog 2>&1 
    
    insertdatasetpath=$logpath/insertdataset/$no4
-   makedir $insertdatasetpath >> $scriptlog 2>&1
+   makedir $insertdatasetpath 
    insertdatasetlog=$insertdatasetpath/insertdataset-$no3.log
 
@@ -99,20 +87,16 @@
    check0=`root -q -b $macrospath/insertdataset.C+\("\"$no2\""\,"\"$source\""\,"\"$wobble\""\,"\"$comment\""\,kFALSE\) | tee $insertdatasetlog | intgrep`
    case $check0 in 
-      1)   echo " check0=$check0 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO dataset $no2 successfully inserted"
+      1)   printprocesslog "INFO dataset $no2 successfully inserted (check0=$check0)"
            ;;
-      3)   echo " check0=$check0 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO dataset $no2 exists already"
+      3)   printprocesslog "INFO dataset $no2 exists already (check0=$check0)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check0=$check0)"
            check="no"
            ;;
-      *)   echo " check0=$check0 -> ERROR " >> $scriptlog 2>&1 
-           printprocesslog "ERROR $program.C failed for dataset $no2"
+      *)   printprocesslog "ERROR $program.C failed for dataset $no2 (check0=$check0)"
            ;;
    esac
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 9355)
@@ -97,5 +97,5 @@
       column=${scriptscolname[$i]}
       getstatus >> $jmscriptlog 2>&1
-      echo " $numproc ${scripts[$i]} still do to" >> $jmscriptlog 2>&1
+      echo " $numproc ${scripts[$i]} still to do" >> $jmscriptlog 2>&1
       if [ "$numproc" = "" ]
       then 
Index: trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 9355)
@@ -41,10 +41,7 @@
 set -C
 
-scriptlog=$runlogpath/$program`date +%F`.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 callistorcseq=callisto.rc
@@ -56,6 +53,6 @@
 if [ ${#primaries[@]} -eq 0 ]
 then 
-   echo "nothing to do -> exit"  >> $scriptlog 2>&1
-   finish >> $scriptlog 2>&1
+   printprocesslog "INFO nothing to do -> exit" 
+   finish 
 fi
 num=`expr ${#primaries[@]} / 2 `
@@ -69,12 +66,12 @@
    telnum=${primaries[$s+$s+1]}
    callistorc=$datapath/callisto/`printf %08d $sequence | cut -c 0-4`/`printf %08d $sequence`/$callistorcseq
-   if ! ls -l $callistorc 2>/dev/null | grep $callistorcnew >> $scriptlog 2>&1
+   if ! ls -l $callistorc 2>/dev/null | grep $callistorcnew 
    then 
       printprocesslog "INFO linking $callistorcnew to $callistorc for sequ $sequence"
       # resetting the calibration
-      echo "resetting the callisto for sequence $sequence" >> $scriptlog 2>&1
+      printprocesslog "INFO resetting the callisto for sequence $sequence" 
 
       query="UPDATE SequenceProcessStatus set fStartTime=NULL, fFailedTime=NULL, fProgramId=NULL, fReturnCode=NULL where fSequenceFirst=$sequence and fTelescopeNumber=$telnum"
-      if ! sendquery >> $scriptlog 2>&1
+      if ! sendquery 
       then 
          printprocesslog "ERROR resetting calibration failed for sequence $sequence"
@@ -85,5 +82,5 @@
       
       #linking callisto.rc
-      if ln -vfs $setuppath/callisto/$callistorcnew $callistorc >> $scriptlog 2>&1
+      if ln -vfs $setuppath/callisto/$callistorcnew $callistorc 
       then 
          printprocesslog "INFO link callisto.rc successfully for sequence $sequence"
@@ -95,4 +92,4 @@
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/mcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 9355)
@@ -37,10 +37,7 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
                                               
 # find montecarlo directories, build two sequences per directory and write sequence files
@@ -58,10 +55,10 @@
       continue
    fi
-   echo $dir >> $scriptlog 2>&1
+   printprocesslog "INFO dir: "$dir 
    
    epochs=`ls -l $mcpath/camera | cut -c 52-80`
    for epoch in ${epochs[@]}
    do
-      echo $epoch >> $scriptlog 2>&1
+      printprocesslog "INFO epoch: "$epoch 
       calfile=`find $dir -lname *${epoch}/*.root | grep "_C_"`
       pedfile=`find $dir -lname *${epoch}/*.root | grep "_P_"`
@@ -140,7 +137,6 @@
             trainno=`echo $firstruntrain | cut -c 0-4`
             trainsequpath=$mcsequpath/$trainno
-            makedir $trainsequpath >> $scriptlog 2>&1
+            makedir $trainsequpath 
             trainsequfile=$trainsequpath/sequence$firstruntrain.txt
-            echo "writing train sequfile "$trainsequfile >> $scriptlog 2>&1
             printprocesslog "INFO writing train sequencefile $trainsequfile"
    
@@ -205,7 +201,6 @@
             testno=`echo $firstruntest | cut -c 0-4`
             testsequpath=$mcsequpath/$testno
-            makedir $testsequpath >> $scriptlog 2>&1
+            makedir $testsequpath 
             testsequfile=$testsequpath/sequence$firstruntest.txt
-            echo "writing test sequfile "$testsequfile >> $scriptlog 2>&1
             printprocesslog "INFO writing test sequencefile $testsequfile"
    
@@ -227,4 +222,4 @@
 done
 
-finish >> $scriptlog 2>&1
-
+finish 
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 9355)
@@ -41,13 +41,10 @@
 umask 0002
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check whether script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # change permission for files
-ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
+ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* 
 
 # find rawfiles belonging to tape (don't move files not yet md5-sum checked)
@@ -56,6 +53,6 @@
 if [ "$rawfiles" == "" ]
 then
-   echo "no files to move -> exit" >> $scriptlog 2>&1
-   finish >> $scriptlog 2>&1
+   printprocesslog "INFO no files to move -> exit" 
+   finish 
 fi
 
@@ -75,5 +72,4 @@
       newrawfile=`echo $rawfile | sed -e 's/\/fromtape\/muxdata//g' -e 's/_/\//1' -e 's/_/\//1'`
    else
-      echo "ERROR something is wrong with the path of file $rawfile -> continue" >> $scriptlog 2>&1
       printprocesslog "ERROR moving rawfile $rawfile failed"
       continue
@@ -81,14 +77,13 @@
    
    newdir=`dirname $newrawfile`
-   makedir $newdir >> $scriptlog 2>&1
+   makedir $newdir 
    
-   mv -v $rawfile $newrawfile >> $scriptlog 2>&1
+   mv -v $rawfile $newrawfile 
 done
 
-rmdir -v /magic/{datacenter,data/rawfiles}/fromtape/???data/* >> $scriptlog 2>&1
+rmdir -v /magic/{datacenter,data/rawfiles}/fromtape/???data/* 
 
 printprocesslog "INFO launching filesondisk"
-echo "launching filesondisk" >> $scriptlog 2>&1
 $scriptspath/filesondisk &
 
-finish >> $scriptlog 2>&1
+finish 
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles_OK
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles_OK	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles_OK	(revision 9355)
@@ -43,14 +43,11 @@
 umask 0002
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check whether script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # change permission for files
-ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
-ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/ >> $scriptlog 2>&1
+ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* 
+ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/ 
 # output for chmod with -v or -c (only changes)
 
@@ -61,23 +58,23 @@
 then
    # change permission for this directories
-   ssh lapalma@dc09 chmod -R g+w $dirs >> $scriptlog 2>&1
+   ssh lapalma@dc09 chmod -R g+w $dirs 
    # move directories to the tapedirectory
    dates=`find /magic/datacenter/fromlapalma/RAW/*200* -type d | cut -d/ -f6`
    for date in ${dates[@]}
    do
-	ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date >> $scriptlog 2>&1
-      	makedir /magic/datacenter/fromtape/rawdata/$date >> $scriptlog 2>&1
+	ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date 
+      	makedir /magic/datacenter/fromtape/rawdata/$date 
         
    	OKs=`ls /magic/datacenter/fromlapalma/RAW/$date/*.OK`
       	for OK in ${OKs[@]}
         do
-		ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/ >> $scriptlog 2>&1
+		ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/ 
                 files=`echo $OK | sed -e 's/.OK//g'`
-		mv -v $files /magic/datacenter/fromtape/rawdata/$date/ >> $scriptlog 2>&1
+		mv -v $files /magic/datacenter/fromtape/rawdata/$date/ 
 	done
    done
 fi
 
-rmdir -v /magic/datacenter/fromlapalma/RAW/*200* >> $scriptlog 2>&1
+rmdir -v /magic/datacenter/fromlapalma/RAW/*200* 
 
 # find rawfiles
@@ -86,6 +83,6 @@
 if [ "$rawfiles" == "" ]
 then
-   echo "no files to move -> exit" >> $scriptlog 2>&1
-   finish >> $scriptlog 2>&1
+   printprocesslog "INFO no files to move -> exit" 
+   finish 
 fi
 
@@ -97,15 +94,14 @@
    newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
    newdir=`dirname $newrawfile`
-   makedir $newdir >> $scriptlog 2>&1
+   makedir $newdir 
    
-   mv -v $rawfile $newrawfile >> $scriptlog 2>&1
+   mv -v $rawfile $newrawfile 
 done
 
-rmdir -v /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
+rmdir -v /magic/datacenter/fromtape/rawdata/* 
 
 printprocesslog "INFO launching filesondisk"
-echo "launching filesondisk" >> $scriptlog 2>&1
 $scriptspath/filesondisk&
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcamera
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcamera	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcamera	(revision 9355)
@@ -63,22 +63,17 @@
 
 
-scriptlog=$runlogpath/run$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # get sequence # 
-gettodo >> $scriptlog 2>&1
+gettodo 
 run=$process
 
 # lock sequ
 lockfile=$lockpath/lock-$table-$column-$sequence.txt
-checklock >> $scriptlog 2>&1
+checklock 
 
-echo "run $program for run $run..." >> $scriptlog 2>&1
 printprocesslog "INFO starting $program for run $run"
 
-setstatus "start" >> $scriptlog 2>&1
+setstatus "start" 
 
-echo "run $program for run $run "
-echo "create input card... "
+printprocesslog "INFO create input card... "
 
 # get values for inputcard
@@ -100,13 +95,6 @@
 seeds=`sendquery`
 
-echo "" >> $scriptlog 2>&1
-echo "INPUTCARD:" >> $scriptlog 2>&1
-echo "----------" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-printinputcard >> $scriptlog 2>&1
-
 logfile=$outpath/$program"-"`printf %06d $run`".log"
-makedir $outpath >> $scriptlog 2>&1
+makedir $outpath 
 
 cd $detectordir/Camera
@@ -121,9 +109,7 @@
 
 case $check1 in
-   0)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
-        printprocesslog "INFO $program finished successfully for sequence $sequence"
+   0)   printprocesslog "INFO $program finished successfully for sequence $sequence (check1=$check1)"
         ;;
-   *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-        printprocesslog "ERROR $program failed for sequence $sequence"
+   *)   printprocesslog "ERROR $program failed for sequence $sequence (check1=$check1)"
         com=$Fcamera
         check=$check1
@@ -131,6 +117,6 @@
 esac
 
-setstatus "stop" >> $scriptlog 2>&1
+setstatus "stop" 
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcorsika
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 9355)
@@ -111,9 +111,6 @@
 
 
-scriptlog=$runlogpath/run$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # get sequence # 
-gettodo "1" >> $scriptlog 2>&1
+gettodo "1" 
 run=${primaries[0]}
 # get corsika runno
@@ -125,13 +122,12 @@
 # lock sequ
 lockfile=$lockpath/lock-$table-$column-$corsikarunno.txt
-checklock >> $scriptlog 2>&1
+checklock 
 
-echo "run $program for run $run..." >> $scriptlog 2>&1
 printprocesslog "INFO starting $program for run $run"
 
-setstatus "start" >> $scriptlog 2>&1
+setstatus "start" 
 
-echo "run $program for run $run " >> $scriptlog 2>&1
-echo "create input card... " >> $scriptlog 2>&1
+printprocesslog "INFO run $program for run $run " 
+printprocesslog "INFO create input card... " 
 
 # get values for inputcard
@@ -169,13 +165,6 @@
 diameter=`sendquery`
 
-echo "" >> $scriptlog 2>&1
-echo "INPUTCARD:" >> $scriptlog 2>&1
-echo "----------" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-printinputcard >> $scriptlog 2>&1
-
 logfile=$outpath/$program"-"`printf %06d $corsikarunno`".log"
-makedir $outpath >> $scriptlog 2>&1
+makedir $outpath 
 
 cd $corsikapath
@@ -192,9 +181,7 @@
 
 case $check1 in
-   0)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
-        printprocesslog "INFO $program finished successfully for corsika run number $corsikarunno"
+   0)   printprocesslog "INFO $program finished successfully for corsika run number $corsikarunno (check1=$check1)"
         ;;
-   *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-        printprocesslog "ERROR $program failed for corsika run number $corsikarunno"
+   *)   printprocesslog "ERROR $program failed for corsika run number $corsikarunno (check1=$check1)"
         com=$Fcorsika
         check=$check1
@@ -202,6 +189,6 @@
 esac
 
-setstatus "stop" >> $scriptlog 2>&1
+setstatus "stop" 
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runreflector
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runreflector	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runreflector	(revision 9355)
@@ -59,10 +59,6 @@
 }
 
-
-scriptlog=$runlogpath/run$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # get sequence # 
-gettodo "1">> $scriptlog 2>&1
+gettodo "1" 
 run=${primaries[0]}
 # get reflector runnumber
@@ -72,13 +68,11 @@
 # lock sequ
 lockfile=$lockpath/lock-$table-$column-$reflectorrunno.txt
-checklock >> $scriptlog 2>&1
+checklock 
 
-echo "run $program for run $run..." >> $scriptlog 2>&1
 printprocesslog "INFO starting $program for run $run"
 
-setstatus "start" >> $scriptlog 2>&1
+setstatus "start" 
 
-echo "run $program for run $run "
-echo "create input card... "
+printprocesslog "INFO create input card... "
 
 # get values for inputcard
@@ -100,12 +94,5 @@
 infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
 
-echo "" >> $scriptlog 2>&1
-echo "INPUTCARD:" >> $scriptlog 2>&1
-echo "----------" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
-printinputcard >> $scriptlog 2>&1
-
-makedir $outpath >> $scriptlog 2>&1
+makedir $outpath 
 if ls $outfile >/dev/null 2>&1
 then
@@ -127,9 +114,7 @@
 
 case $check1 in
-   0)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
-        printprocesslog "INFO $program finished successfully for run $reflectorrunno"
+   0)   printprocesslog "INFO $program finished successfully for run $reflectorrunno (check1=$check1)"
         ;;
-   *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-        printprocesslog "ERROR $program failed for run $reflectorrunno"
+   *)   printprocesslog "ERROR $program failed for run $reflectorrunno (check1=$check1)"
         com=$Freflector
         check=$check1
@@ -137,6 +122,6 @@
 esac
 
-setstatus "stop" >> $scriptlog 2>&1
+setstatus "stop" 
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9355)
@@ -60,5 +60,4 @@
             rm -v $lockfile
          fi
-         date
          exit
       fi
@@ -90,5 +89,4 @@
       rm -v $lockfile
    fi
-   date
    printprocesslog "INFO finished $0"
    exit
@@ -184,10 +182,10 @@
    checklock0=$?
    case $checklock0 in
-      0)   echo " checklock0=$checklock0 -> continue " ;;
-      1)   echo " checklock0=$checklock0 -> file $lockfile exists"
-           date
+      0)   printprocesslog "INFO checklock0=$checklock0 -> continue " 
+           ;;
+      1)   printprocesslog "WARN checklock0=$checklock0 -> file $lockfile exists"
            $@
            exit;;
-      *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
+      *)   printprocesslog "ERROR checklock0=$checklock0 -> something went completely wrong" ;;
    esac
 }
@@ -218,15 +216,15 @@
 {
    case $@ in
-      start)   echo "setstatus start"
+      start)   printprocesslog "INFO setstatus start"
                starttime="Now()"
                ;;
        stop)   case $check in
-                  ok)  echo "setstatus stop - ok"
+                  ok)  printprocesslog "INFO setstatus stop - ok"
                        statustime="Now()"
                        ;;
-                  no)  echo "setstatus stop - nothing new"
+                  no)  printprocesslog "INFO setstatus stop - nothing new"
                        check="ok"
                        ;;
-                   *)  echo "setstatus stop - failed"
+                   *)  printprocesslog "INFO setstatus stop - failed"
                        starttime=noreset
                        if [ "$check" == "" ]
@@ -242,6 +240,5 @@
                esac
                ;;
-          *)   echo "error -> exit"
-               printprocesslog "ERROR function evalstatus got wrong variable"
+          *)   printprocesslog "ERROR function evalstatus got wrong variable"
                finish
                ;;
@@ -279,5 +276,5 @@
 {
    process=
-   echo "getting todo..."
+   printprocesslog "INFO getting todo..."
    getdbsetup
    getstepinfo
@@ -303,8 +300,7 @@
       query=$query" limit 0, $@ "
    fi
-   echo " QUERY: "$query
+   printprocesslog "INFO QUERY: "$query
    if ! process=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    then
-      echo "ERROR could not query processes from db -> exit"
       printprocesslog "ERROR could not query processes from db (program: $program, function gettodo)"
       finish
@@ -313,5 +309,5 @@
    if [ "$process" = "" ]
    then
-      echo "  => nothing to do"
+      printprocesslog "INFO => nothing to do"
       finish
    else
@@ -340,8 +336,7 @@
    query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) "
    query=$query" group by $column "
-#   echo " QUERY: "$query
+#   printprocesslog "INFO  QUERY: "$query
    if ! numproc=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    then
-      echo "ERROR could not query number of todo proceses from db -> continue"
       printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus)"
       cont
@@ -364,6 +359,5 @@
    if [ "$reset" = "no" ]
    then
-      echo "YOU CAN'T RESET $column for ${primaries[$s+$s]}!!!"
-      printprocesslog "ERROR you can't reset $column for ${primaries[$s+$s]}"
+      printprocesslog "ERROR You cannot reset $column for ${primaries[$s+$s]}"
       finish
    fi
@@ -391,8 +385,7 @@
       query=$query" and ${prims[$i]}='${primaries[$s*${#prims[@]}+$i]}' "
    done   
-   echo " QUERY: "$query
+   printprocesslog "INFO QUERY: "$query
    if ! mysql -s -u $us --password=$pw --host=$ho $db -e " $query "
    then
-      echo "ERROR could not insert status into db -> exit"
       printprocesslog "ERROR could not set status in db (program: $program, function setstatus)"
       finish
Index: trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles	(revision 9355)
@@ -41,13 +41,10 @@
 column=fDataSetFileWritten
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -56,28 +53,24 @@
 do
    dataset=${primaries[$s]}
-   echo "writing dataset file for dataset $dataset..." >> $scriptlog 2>&1 
    printprocesslog "INFO writing datasetfile for dataset $dataset"
    no=`printf %08d $dataset | cut -c 0-5`
    no2=`printf %08d $dataset`
    datasetpathcpl=$datasetpath/$no
-   makedir $datasetpathcpl >> $scriptlog 2>&1 
+   makedir $datasetpathcpl 
    writedatasetfilelogpath=$logpath/$program/$no
-   makedir $writedatasetfilelogpath >> $scriptlog 2>&1 
+   makedir $writedatasetfilelogpath 
    logfile=$writedatasetfilelogpath/$program-$no2.log
 
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
    
    check1=`root -q -b $macrospath/writedatasetfile.C+\($dataset\,\""$datasetpathcpl\""\) | tee $logfile | intgrep`
 
    case $check1 in
-      1)   echo " check1=$check1 -> everything ok" >> $scriptlog 2>&1 
-           printprocesslog "INFO wrote datasetfile for dataset $dataset successfully"
+      1)   printprocesslog "INFO wrote datasetfile for dataset $dataset successfully (check1=$check1)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check1=$check1 -> ERROR " >> $scriptlog 2>&1 
-           printprocesslog "ERROR writedatasetfile.C failed"
+      *)   printprocesslog "ERROR writedatasetfile.C failed (check1=$check1)"
            com=$Fwritedatasetfile
            check=$check1
@@ -85,7 +78,7 @@
    esac
    
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 9354)
+++ trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 9355)
@@ -42,13 +42,10 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 # get todo list
-gettodo  >> $scriptlog 2>&1
+gettodo 
 
 cd $mars
@@ -63,32 +60,28 @@
    no2=`printf %08d $sequence`
    sequencepath=$sequpath/$no
-   makedir $sequencepath >> $scriptlog 2>&1
+   makedir $sequencepath 
 
    writesequencefilelogpath=$logpath/$program/$no
-   makedir $writesequencefilelogpath >> $scriptlog 2>&1
+   makedir $writesequencefilelogpath 
    writesequencefilelog=$writesequencefilelogpath/writesequencefile-$no2.log
 
-   echo "write sequencefile for sequence $sequence" >> $scriptlog 2>&1
-   setstatus "start" >> $scriptlog 2>&1
+   setstatus "start" 
 
-   check2=`root -q -b $macrospath/writesequencefile.C\($sequence\,$telnum\,"\"$sequpath\""\) | tee $writesequencefilelog | intgrep`
-   case $check2 in
-      1)   echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO sequence file successfully written for sequence $sequence"
+   check1=`root -q -b $macrospath/writesequencefile.C\($sequence\,$telnum\,"\"$sequpath\""\) | tee $writesequencefilelog | intgrep`
+   case $check1 in
+      1)   printprocesslog "INFO sequence file successfully written for sequence $sequence (check1=$check1)"
            ;;
-      0)   echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check1=$check1)"
            check="no"
            ;;
-      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-           printprocesslog "ERROR $program.C failed for sequence $sequence"
+      *)   printprocesslog "ERROR $program.C failed for sequence $sequence (check1=$check1)"
            com=$Fwritesequfile
-           check=$check2
+           check=$check1
            ;;
    esac
    
-   setstatus "stop" >> $scriptlog 2>&1
+   setstatus "stop" 
 done
 
-finish >> $scriptlog 2>&1
+finish 
 
