Sometimes a long-running process will start to perform it's tasks much slower than it should, or in a strange order. It'd be lovely to know what the process is doing but strace produces a deluge of information that is several levels below what you want to know. What can you do?

Well, we could ask the process to turn on debugging output while it's still running. How does that sound?

trap("USR1") do
  @logger.level = $DEBUG ? Logger::DEBUG : Logger::INFO "USR1 received. Turning #{$DEBUG ? 'on' : 'off'} debugging."

Now whenever you need more debugging information simple send a USR1 signal to your process.

kill -USR1 [pid]
written by
Disagree? Found a typo? Got a question?
If you'd like to have a conversation about this post, email I don't bite.
You can verify that I've written this post by following the verification instructions:
curl -LO
curl -LO
gpg --verify using-signals-to-debug-long-running-processes.html.orig{.asc,}