Index: trunk/MagicSoft/Mars/datacenter/scripts/linkmc
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 7938)
+++ trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 7944)
@@ -42,17 +42,15 @@
 #
 
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
 program=linkmc
-source `dirname $0`/sourcefile
 
 set -C
 
-scriptlogpath=$runlogpath/$program
-makedir $scriptlogpath
-scriptlog=$scriptlogpath/linkmc`date +%F`.log
-
+scriptlog=$runlogpath/$progam-`date +%F`.log
 date >> $scriptlog 2>&1
 
 # check if script is already running
-lockfile=$lockpath/lock-mclinks.txt
+lockfile=$lockpath/lock-$program.txt
 checklock  >> $scriptlog 2>&1
 
@@ -67,6 +65,6 @@
 then
    echo "file $next not found -> no start-runno -> exit" >> $scriptlog 2>&1
-   rm -v $lockfile >> $scriptlog 2>&1
-   exit
+   printprocesslog "ERROR file $next (last runno) not found"
+   finish >> $scriptlog 2>&1
 fi
 
@@ -116,4 +114,5 @@
 camfiles=`find $mccampath -type f | grep -v Cal_and_Ped`
 
+printprocesslog "INFO linking new camerafiles starting with runno $runno"
 for camfile in ${camfiles[@]}
 do 
@@ -123,4 +122,5 @@
       continue
    fi
+   printprocesslog "INFO linking $file"
    file=`basename $camfile` #filename
    no=`printf %08d $runno | cut -c 0-5` #first 5 digits of a 8digit runno -> for path
@@ -177,4 +177,5 @@
 done
 
+printprocesslog "INFO linking cal and ped files"
 echo "linking cal and ped file" >> $scriptlog 2>&1
 #get files
@@ -188,6 +189,6 @@
 then 
    "too many files in the directory $mccampath/Cal_and_Ped -> exit" >> $scriptlog 2>&1
-   rm -v $lockfile >> $scriptlog 2>&1
-   exit
+   printprocesslog "ERROR too many ped and cal files found in $mccampath/Cal_and_Ped"
+   finish >> $scriptlog 2>&1
 fi
 
@@ -225,8 +226,4 @@
 done
 
-rm -v $lockfile >> $scriptlog 2>&1
-
-set +C
-
-date  >> $scriptlog 2>&1
-
+finish >> $scriptlog 2>&1
+
