Debugging init scripts: set -x

2011-02-19   

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

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

From man set:

-x

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