Changeset 32749

Show
Ignore:
Timestamp:
07.02.2019 16:18:35 (11 days ago)
Author:
ak19
Message:

More Western Wilson stuff: finally got the bash script working. Cron task file is still a sample at present

Location:
other-projects/the-macronizer/trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • other-projects/the-macronizer/trunk/src/java/util/MacroniserLogFileProcessor.java

    r32745 r32749  
    5858 
    5959            sqlAccess.makeConnection(); 
     60 
     61            System.out.println("Sending " + extractedEntries.size() + " entries to DB..."); 
    6062 
    6163            //loop through all entries 
  • other-projects/the-macronizer/trunk/src/java/util/MySQLAccess.java

    r32746 r32749  
    6060    private String PASSWORD; //= "pinky"; 
    6161 
    62     private final String PROPS_FILENAME = "mysql.properties"; // set to "properties/mysql.properties" for IntelliJ 
     62    private final String PROPS_FILENAME = "classes/mysql.properties"; // set to "classes/mysql.properties" for IntelliJ 
    6363 
    6464    //Makes a connection to the server 
  • other-projects/the-macronizer/trunk/src/scripts-and-sql/cron.txt

    r32747 r32749  
    2323 
    2424#* 0 * * * /PATH/TO/macronLogToDB.bash > /dev/null 
     25 
     26## Stdout goes to the .out file and stderr will go to an .err file 
    2527* 0 * * * /PATH/TO/macronLogToDB.bash > /PATH/TO/macronLogToDB.out 
    2628 
  • other-projects/the-macronizer/trunk/src/scripts-and-sql/macronLogToDB.bash

    r32747 r32749  
    1818 
    1919################################### 
    20 macronlogs_folder=/home/wjkw1/comp520/MacroniserLogs/tmp/ #/home/wjkw1/comp520/MacroniserLogs/logs #/Scratch/wjkw1/macron-restoration/web/logs 
     20macronlogs_folder=/home/wjkw1/comp520/MacroniserLogs/tmp #/home/wjkw1/comp520/MacroniserLogs/logs #/Scratch/wjkw1/macron-restoration/web/logs 
    2121#macronLogToDBjar= 
    2222exec_folder=/home/wjkw1/IdeaProjects/LogFileExtraction/out/production/LogFileExtraction 
     
    2626email_address=wilsonw9378@gmail.com #tetaka1@gmail.com 
    2727jars_folder=/Scratch/wjkw1/mysql-connector-java-8.0.14 #/Scratch/wjkw1/macron-restoration/web/WEB-INF/lib 
    28 mysqlprops_folder=/Scratch/wjkw1/properties #/Scratch/wjkw1/macron-restoration/web/WEB-INF/classes 
     28mysqlprops_folder=/Scratch/wjkw1/classes #/Scratch/wjkw1/macron-restoration/web/WEB-INF/classes 
    2929 
    30 echo "HELLO WORLD" 
     30echo "" 
     31echo "In script $0 to process macron.log.* files" 
     32echo "  Note that any logfile named exactly 'macron.log' (instead of matching macron.log.*) will not be processed" 
    3133 
    3234# get rid of any old error files 
     
    4345mkdir -p $reprocess_folder 
    4446 
    45 pushd $macronlogs_folder > /dev/null 
     47 
    4648# "Bash does carry out filename expansion [1] -- a process known as globbing" 
    4749# https://www.tldp.org/LDP/abs/html/globbingref.html 
     
    5052#  Correct glob use: 
    5153#  Always use for-loop, prefix glob, check if exists file. 
    52 for logfile in ./macron.log.* ; do         # Use ./* ... NEVER bare * 
    53   if [ -e "$logfile" ] ; then   # Check whether file exists. 
    54       echo "****** $0 script processing $logfile"       
     54for logfile in $macronlogs_folder/macron.log.* ; do         # Use ./* ... NEVER bare * [EDIT: if in current folder?] 
     55    if [ -e "$logfile" ] ; then   # Check whether file exists. 
     56      echo "****** processing $logfile"       
    5557 
    5658      # https://askubuntu.com/questions/625224/how-to-redirect-stderr-to-a-file 
    5759 
    58       # this works: java -cp /Scratch/wjkw1/mysql-connector-java-8.0.14/mysql-connector-java-8.0.14.jar:/Scratch/wjkw1/properties/mysql.properties:. util.MacroniserLogFileProcessor /home/wjkw1/comp520/MacroniserLogs/tmp/macron.log 
    59       #java -cp $jars_folder/mysql-connector-java-8.0.14.jar:$mysqlprops_folder:. util.MacroniserLogFileProcessor $logfile > /dev/null 2>> $errfile 
    60  
    61       echo "java -cp $exec_folder:$jars_folder/mysql-connector-java-8.0.14.jar:$mysqlprops_folder:. util.MacroniserLogFileProcessor $logfile > /dev/null 2>> $errfile" 
    62       java -cp $exec_folder:$jars_folder/mysql-connector-java-8.0.14.jar:$mysqlprops_folder:. util.MacroniserLogFileProcessor $logfile       
    63       
     60      echo "Running command:" 
     61      echo "   java -cp .:$exec_folder:$jars_folder/mysql-connector-java-8.0.14.jar:$mysqlprops_folder util.MacroniserLogFileProcessor $logfile 2>> $errfile" 
     62      echo "" 
     63      java -cp .:$exec_folder:$jars_folder/mysql-connector-java-8.0.14.jar:$mysqlprops_folder util.MacroniserLogFileProcessor $logfile 2>> $errfile 
     64       
     65       
    6466      # The above returns 0 on success, -1 on failure 
    6567      # if 0, then move $logfile to processed_folder 
     
    8284#  Correct glob use: 
    8385#  Always use for-loop, prefix glob, check if exists file. 
    84 for file in ./macron.log.* ; do         # Use ./* ... NEVER bare * 
    85   if [ -e "$file" ] ; then   # Check whether file exists. 
    86      echo "$file" 
    87   fi 
    88 done 
     86#for file in ./macron.log.* ; do         # Use ./* ... NEVER bare * 
     87#  if [ -e "$file" ] ; then   # Check whether file exists. 
     88#     echo "$file" 
     89#  fi 
     90#done 
    8991 
    90 echo "GOODBYE" 
     92echo "Finished processing macron.log.* files" 
     93echo "" 
    9194 
    9295# If error file exists and has non-zero size, send email 
     
    102105fi 
    103106 
    104 popd 
    105107 
    106108# Cronjob: https://stackoverflow.com/questions/8938120/how-to-run-cron-once-daily-at-10pm