5 if [ $argssize -ne 3 ];then
7 echo "Usage: ./ProcessNewFilesEVD.sh {maximum number of jobs to run} {version} {compiler}"
9 echo "Example: ./ProcessNewFilesEVD.sh 4 v04_30_03 e9"
20 echo "Processing 35t nearline Event Display with maxjobs: $maxjobs"
26 # Check Disk space before making a mess
27 export DiskUsage=`df /home -h | awk 'NR==2 && match($5,"%"){print substr($5,RSTART-3,2)}'`
28 if [ $DiskUsage -gt 95 ];then
30 echo "Disk too full..."
31 echo "nearline home disk for 35t machine is $DiskUsage % full."
32 echo "All processing will be stopped until you clear out some space."
38 export DiskUsage2=`df /lbne/data2 -h | awk 'NR==3 && match($4,"%"){print substr($4,RSTART-3,2)}'`
39 if [ $DiskUsage2 -gt 95 ];then
41 echo "Disk too full..."
42 echo "nearline-data disk for 35t machine is $DiskUsage % full."
43 echo "All processing will be stopped until you clear out some space."
51 # Test to see if this job is already running.
52 if [ -e /tmp/Batch-35t-NearlineEVD.LOCK ];then
53 if [ $(( $(date +%s) - $(stat -c %Y /tmp/Batch-35t-NearlineEVD.LOCK) )) -gt 14400 ];then
55 echo ".LOCK file is older than 4 hours..."
56 echo "There is a stale lock file that needs attention."
57 echo "Machine: $(hostname)"
58 echo "File: /tmp/Batch-35t-NearlineEVD.LOCK"
59 echo "ProcessNewFilesEVD.sh skipped this file at $(date)."
61 echo "lock file /tmp/Batch-35t-NearlineEVD.LOCK exists. Exiting..."
67 touch /tmp/Batch-35t-NearlineEVD.LOCK
72 # Setup necessary pathways:
73 export RelDir=/home/lbnedaq/nearline/nearline_test_release_${version}
74 export ScriptPath=${RelDir}/srcs/dunetpc/dune/NearlineMonitor/scripts
75 export LPDir=${RelDir}/localProducts_larsoft_${version}_${comp}_prof
76 export OutputPath=/lbne/data2/users/lbnedaq/nearline_evd/${version}
77 export OutputSearchPath=/lbne/data2/users/lbnedaq/nearline_evd/v*
78 export BaseFileName=lbne_r
79 export FileSearch='/data/lbnedaq/data/transferred_files/lbne_r*.root'
84 # Only look for new files between 10 min and 1 day old and sort them so that files
85 # with the largest run/subrun numbers are first in the list.
86 for file in $( find ${FileSearch} -mtime -0.5 -mmin +10 | sort -t "/" -k$filepos -r )
89 if [ `ps aux | grep ProcessSingleFileEVD | wc -l` -gt $maxjobs ];then
91 echo "Reached the max number of running jobs. Exiting..."
94 rm -fv /tmp/Batch-35t-NearlineEVD.LOCK
100 export bigrun=${FILE:6:3}
101 export run=${FILE:6:6}
102 export subrun=${FILE:15:2}
103 export RunDir=$OutputPath/$bigrun/${run}_${subrun} #use subrun as well in case we have subruns
104 export RunSearchDir=$OutputSearchPath/$bigrun/${run}_${subrun} #use subrun as well in case we have subruns
108 num_files=`find $RunSearchDir/${FILE}EVD.DONE 2>/dev/null | wc -l`
110 # Check if this file has already been processed or is curently being processed.
111 if [ $num_files -gt 0 ];then
112 # echo "SKIP: $FILE has already been processed."
116 num_files=`find $RunSearchDir/${FILE}EVD.LOCK 2>/dev/null | wc -l`
118 if [ $num_files -gt 0 ];then
119 # echo "SKIP: $FILE is currently being processed."
123 # execute script to process single file
124 echo "Processing $file"
127 # There is too much text output in these jobs. So for now, don't pipe it
129 # nohup ./ProcessSingleFile.sh $RunDir $file $LPDir > $RunDir/$FILE.log 2>&1 &
130 nohup ./ProcessSingleFileEVD.sh $RunDir $file $LPDir >> /dev/null 2>&1 &
136 rm -fv /tmp/Batch-35t-NearlineEVD.LOCK