Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_condor_cleanup.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // remove broken symbolic links in condor log dir (avoid init condor failure)
20 // to be used when jobs are in held status
21 
22 {
23  #include <vector>
24 
26 
27  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
28  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
29  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
30 
31  // condor log dirs
32  char full_condor_log_dir[1024];
33  sprintf(full_condor_log_dir,"%s/%s",work_dir,log_dir);
34 
35  vector<TString> fileList = TB.getFileListFromDir(full_condor_log_dir, "", "","",true);
36 
37  int cnt=0;
38  char cmd[1024];
39  for(int i=0;i<fileList.size();i++) {
40  TString path;
41  Long_t id,size,flags,mt;
42  path = CWB::Toolbox::getFileName((char*)fileList[i].Data());
43  if(path!="") {
44  int estat = gSystem->GetPathInfo(path.Data(),&id,&size,&flags,&mt);
45  if(estat!=0) { // condor log out,err symbolic link is broken
46  sprintf(cmd,"rm -f %s",fileList[i].Data());
47  gSystem->Exec(cmd);
48  cnt++;
49  }
50  }
51  }
52  cout << endl;
53  cout << "Cleaned condor log files : " << cnt << endl;
54  cout << endl;
55 
56  gSystem->Exit(0);
57 }
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:5108
char cmd[1024]
TString("c")
CWB::Toolbox TB
Long_t flags
vector< TString > fileList
Long_t size
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
char log_dir[512]
Definition: test_config1.C:151
int estat
int cnt
Long_t mt
char full_condor_log_dir[1024]
static TString getFileName(FILE *fp)
Definition: Toolbox.cc:6780
Long_t id
char work_dir[512]
Definition: test_config1.C:143
sprintf(full_condor_log_dir,"%s/%s", work_dir, log_dir)