Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:45

0001 #!/bin/tcsh 
0002 
0003 #
0004 # so: try and have files lasting at least $retention_time; 
0005 #
0006 #
0007 # dquota is the quota of the area
0008 # minfree must be the minimum free area to complete current operations
0009 #
0010 
0011 # if disk used more than $maxdisk, delete the oldest ones respecting the previous requirement
0012 # if disk used more than $maxdisk, delete the oldest ones without respecting the previous requirement, but then send a WARNING
0013 
0014 
0015 set verb=0
0016 
0017 set AREA=/afs/cern.ch/cms/CAF/CMSCOMM/COMM_GLOBAL/EventDisplay/RootFileTempStorageArea
0018 
0019 #
0020 # in hours
0021 #
0022 
0023 set retention_time=1
0024 
0025 #
0026 # disk quota (in kB)
0027 #
0028 
0029 # this is 10 GB
0030 set dquota=10000000
0031 
0032 #
0033 # minfree (in kB)
0034 #
0035 
0036 # this is 1 GB
0037 set minfree=1000000
0038 
0039 @ maxdisk= $dquota - $minfree
0040 
0041 if ($verb) then
0042     echo Setting maxdisk to $maxdisk
0043 endif
0044 #
0045 # get disk used
0046 #
0047 cd $AREA
0048 set used=`du -s |awk '{print $1}'`
0049 
0050 if ($verb) then
0051     echo Used disk is $used
0052 endif
0053 
0054 
0055 if ($used < $maxdisk) then
0056 #
0057 # nothing to do
0058 #
0059 if ($verb) then
0060     echo Exit with code 0
0061 endif
0062 
0063 exit 0
0064 endif
0065 
0066 # first test - see if you can clean applying retention time
0067 if ($used > $maxdisk) then
0068 if ($verb) then
0069     echo Running tmpwatch
0070 endif
0071 echo    tmpwatch --verbose --atime $retention_time . 
0072 endif
0073 #
0074 # now look whether situation is good
0075 #
0076 set newused=`du -s |awk '{print $1}'`
0077 
0078 if ($verb) then
0079     echo Now used is $newused
0080 endif
0081 
0082 if ($newused < $maxdisk) then
0083 #
0084 # I am happy, I bail out
0085 # exit 2 = i had to delete, but just stuff I could delete
0086 exit 2
0087 endif
0088 
0089 #
0090 # else, delete files in order of age, one by one
0091 #
0092 while ($newused > $maxdisk)
0093  #
0094  # find the oldest file
0095  set file=`ls -t1|tail -1`
0096 
0097 
0098  echo rm -f $file
0099  #calculate new disk free
0100  set newused=`du -s |awk '{print $1}'`
0101 #
0102 end
0103 
0104 #exit three means I had to delete stuff not expired
0105 exit 3
0106 
0107 #