I know one way i.e. ./filename.sh > log.txt. But that log file is containing the content what appears in console if we run the file using ./filename.sh. Background process is not appearing in log file. By background process I mean how compiler is evaluating each and every line (the word debug suits that, I guess).How to get that background process into a log file? 
How to see what's going in background when we run a .sh file in Linux?
shell script
Based on your comment:I mean I would like to know 'How bash is executing each and every line of shell script' when running a .sh file..If you are using bash, then what you're looking for is:bash -x ./filename.shorbash -x ./filename.sh > log.txtAlternatively you can add:set -xto the content of filename.sh.