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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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