How to see what’s going in background when we run a .sh file in Linux? [closed]

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?

Answer

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.sh

or

bash -x ./filename.sh > log.txt

Alternatively you can add:

set -x

to the content of filename.sh.

Leave a Reply

Your email address will not be published. Required fields are marked *