Ubuntu – How to get output from upstart jobs when logged in via SSH

sshupstart

To monitor what my job definitions are doing, I would like to see text output from the jobs. That does not seem to be possible when I am logged on via SSH.

I am having this problem with Natty 11.04, but I am convinced that it is a more common one.

A simple job file I use (filename /etc/init/test.conf):

description "test"
start on test
console owner
kill timeout 5
task
script
  /bin/echo Gotcha...
end script

My goal is to see the text "Gotcha…" when doing initctl emit test or initctl start test. But that does not work.

What I have tried so far:

  • "console output" instead of "console owner"
  • "exec /bin/echo Gotcha…" instead of script…end script

Best Answer

Since init (pid 1) is running the service (which has no stdout/stderr) and not your shell (like with older /etc/init.d-style scripts), there is presently no way to see the output that is generated. (This feature is frequently requested and is on the list of things to do for Upstart.)

To work around this, I recommend forcing output redirection at the start of the job itself:

script
    exec >/var/log/test.debug 2>&1
    echo Gotcha...
end script
Related Question