Ignore:
Timestamp:
2019-02-07T16:18:35+13:00 (2 years ago)
Author:
ak19
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.