Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an upstart script that does the following

start on runlevel [2345]
stop on runlevel [06]


pre-start script
    exec >/dev/kmsg 2>&1
    mkdir -p /var/log
    mkdir -p /var/www
    echo "Fetching app from $REPO"
    girror $REPO /var/www
    if [ -f /var/www/package.json ]; then
        echo "Installing npm modules"
        cd /var/www
        npm install
end script

post-stop script
    exec >/dev/kmsg 2>&1
    echo "stopped"
end script

    exec >/dev/kmsg 2>&1
    export NODE_ENV=production
    export port=80
    echo "Starting app.js on port 80"
    cd /var/www
    node app.js
end script

I am running the script as root. The log files of the application suppose to go to /var/log/syslog but they don't go there.

However, I do see the app log when running dmesg | tail -f

Using kernel 3.5.0-46

Anyone know why it doesn't work ?

share|improve this question

It's happening because your script explicitly redirects all output to dmesg:

exec >/dev/kmsg 2>&1
share|improve this answer
I have the exact script running on a different ubuntu machine on AWS and it is redirecting okay. – Michael Mar 6 '14 at 0:12
@Michael: What kernel version is it running? – grawity Mar 6 '14 at 0:13
the problematic one is running 3.5.0-46-generic #70~precise1-Ubuntu the one that works is running 3.2.0-31-virtual #50-Ubuntu – Michael Mar 6 '14 at 0:16
@Michael: No. Rather, on the working machine, there is no dmesg input at all. Kernels before 3.5 did not have a writable /dev/kmsg device, so the exec line fails, the script ignores errors, and simply continues logging to where it was redirected previously (by Upstart). – grawity Mar 6 '14 at 0:19
@Michael: Your original question does say the opposite – you wrote that it does not work because logs go to dmesg and not syslog. – grawity Mar 6 '14 at 0:25

Your Answer


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.