bash storing the output of set -x to log file -



bash storing the output of set -x to log file -

however automate job. there way save set -x output log file.

maybe 1 log file - or different log file each day. dont know work best.

#!/bin/bash set -x #short_date=$(/bin/date +%m%d%y) short_date=$(/bin/date -d "8 day ago" +%m%d%y) #long_date=$(/bin/date +%y%m%d) long_date=$(/bin/date -d "8 day ago" +%y%m%d) scp -v -p 1332 -i /home/casper/.ssh/id_rsa_bank friendly@192.168.1.10:/home/friendly/transfer/out/exchange_$short_date.csv /local/casper3/dailymetrics/bank_$long_date.csv

this set x output. have simple download script , utilize set -x works great. can see each step , performs, , can identiry error script or n download. automate job. there way save set -x output log file.

maybe 1 log file - or different log file each day. dont know work best.

++ /bin/date +%m%d%y + short_date=102814 ++ /bin/date +%y%m%d + long_date=20141028 + scp -v -p 1332 -i /home/casper/.ssh/id_rsa_bank friendly@192.168.1.10:/home/friendly/transfer/out/exchange_102814.csv /local/casper3/dailymetrics/bank_20141028.csv executing: programme /usr/bin/ssh host 192.168.1.10, user friendly, command scp -v -f /home/friendly/transfer/out/exchange_102814.csv openssh_5.3p1, openssl 1.0.0-fips 29 mar 2010 debug1: reading configuration info /home/casper/.ssh/config debug1: reading configuration info /etc/ssh/ssh_config debug1: applying options * debug1: connecting 192.168.1.10 [192.168.1.10] port 7777. debug1: connection established.

assuming bash 4, bash_xtracefd can set override file descriptor (by default 2, stderr) set -x output written:

short_date=$(/bin/date +%m%d%y) exec {bash_xtracefd}>>"$short_date".log set -x

if running bash 4.0 rather 4.1 or newer, have bash_xtracefd not automatic file descriptor allocation, meaning you'll need assign 1 yourself; in below example, i'm picking file descriptor 100:

short_date=$(/bin/date +%m%d%y) exec 100>>"$short_date".log bash_xtracefd=100 set -x

for older releases, selection redirect of stderr, rather xtrace stream:

short_date=$(/bin/date +%m%d%y) exec 2>>"$short_date.log" set -x

bash output

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -