Server DIY Backup script redirect debug messages to stderr

In "" there is a function called "run", with this comment:

"Log then execute the provided command".

This is the last row of the function:

"debug "Running${cmdline}" > /dev/stderr"


Please explain me why a debug message should go to the stderr instead of the stdout? (it's a debug message!)

1 answer

0 vote

Hi Ezio, it looks to be a general preference to have debugging messages sent to stderr instead of stdout. For example, from Stackoverflow :


Regular output (the actual result of running the program) should go on stdout, things like diagnostic, notice, warning, error, etc, go on stderr.

If there is no "regular output", I would say that it doesn't really matter which one you choose. You could argue that the logging is the only output, so that should go to stdout. Or you could argue that it is still "exceptional information" which should go to stderr.

The backup scripts don't really have regular output, so we 're sending those messages to stderr.
Hope this helps!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,953 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you