- Put the start time in a variable at beginning of script;
command - export start_date=`date +%m/%d/%Y,%H:%M:%S`.
Be careful and use `` this operator to put the date function in a variable. Use the proper date format string as you need. - Put the end in a variable at the end of script;
command - export end_date=`date +%m/%d/%Y,%H:%M:%S`. - Write the log and separate the field using ','.
echo 'start,' $start_date ',end,' $end_date >> scriptexlog.csv
Wednesday, December 8, 2010
Maintain shell script log in CSV
Suppose you want to log the start and end of your shell script execution. Also you want to know the total execution time. Then you should do the followings -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment