Hello all after hours of google searching hoping somebody here can provide direction.
Currently I have a .sh file which I run in putty to kick off a process. The current way I do this is:
sh /filepath/file.sh >> /filepath/file_date.log
While this works; I find it cumbersome to make sure I do the >> and logfile path correct for each of the .sh files I invoke.
The current contents of my .sh file are as such:
#!/bin/bash
set -x
frstdt=`date -d "last monday - 2 week" +"%m%d%Y"`;
scnddt=`date -d "last sunday - 1 week" +"%m%d%Y"`;
tday=`date -d "$date" +"%m_%d_%Y"`;
frstdtem=`date -d "last monday - 2 week" +"%m/%d/%Y"`;
scnddtem=`date -d "last sunday - 1 week" +"%m/%d/%Y"`
cd /filepath/
/filepath/cloak-hive -f query.hql
--Here I use hive -e to get some results from the query and write them to a .csv file.
ehco "Contents of email" | mailx -s "Subject" -a "Attchement" -me@email.com
What I am trying to understand is what I can add to the beginning of the .sh file to log all of the actions that take place, the map/reduce updates HIVE etc. I can see all this now when using the >> command when calling the .sh but am lookign to simplify this for others on the team. I have tried using exec trap exec; | tee and other version of that but can not get anything to work. I do not need to see anything in the console after I enter sh /filepath/filename.sh I just want everthing to show up in the log with the log file name having the dat it runs in the file name(which is why I have tday as a variable; I would like it to show as /filepath/filename_$tday.log