Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a simple upstart script that runs a process and respawns it if it crashes. The problem is if it crashes I want the user to be alerted that it crashed (because they may need to take an action to prevent it from crashing again). Here's my script:

start on runlevel [2345]
stop on runlevel [016]

chdir /opt

respawn
respawn limit 5 10

exec /usr/bin/gulp --gulpfile ./lib/vendor/node/gulpfile.js 2>&1 > /var/log/gulp.log

Not that I redirect standard error into the console (2>&1) and standard out a log file. The log file redirection WORKS. But the standard error to the console does NOT. This error redirection does work if I run the command directly from the shell.

Things I've tried so far: - Adding 'console output' to the script (which supposedly redirects output to /dev/console) - Using exec start-stop-daemon --start -c myuser --exec command (thinking that because I run the upstart job with sudo the /dev/console points somewhere else) **this script just crashes won't even run

Any other ideas? I really need error output to be put into the console for the user.

share|improve this question

1 Answer 1

Omit the 2>&1 - this actually redirects stderr to stdout. You want stderr to go to the console - which is the default for stderr.

exec /usr/bin/gulp --gulpfile ./lib/vendor/node/gulpfile.js > /var/log/gulp.log
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.