Debugging init scripts: set -x


Init script does not behave correctly. How to debug init script?

Use set -x right after #!/bin/sh in init script.

From man set:


The shell shall write to standard error a trace for each command
after it expands the command and before it executes  it.  It  is
unspecified  whether  the  command  that  turns  tracing  off is