I've used the below script both with and without expect fork. It's purpose is to start a .exe file on start-up, and if it fails, to restart it. The mono application must be started by root/sudo to work.

What happens:

  • Application Starts and shows Listening to port 8888 in output log
  • Upstart goes into respawn and tries to restart the script despite it already being started
  • An error message per respawn attempt appears in the output log saying that the application is already running
  • After an hour or so, the application fails/stops, and respawn is not triggered

Here is my upstart script:

author "me"
description "hi"

start on local-filesystems
stop on shutdown

console log
respawn limit 2 5

env DIR=/home/danny
env PATH=/sbin:/usr/sbin:/usr/local/bin:/user/bin:/bin

expect fork
    set -x
    /usr/bin/mono /home/danny/path-to-my.exe
end script

Any/all help is appreciated. I'm a little stumped on this one.


since the file is an EXE it is likely that you need a different way of detecting if it is running due to the fact that EXEs are run through wine and so are different than the programs native to ubuntu

  • Is there a way to tell Upstart to use a different method to detect start/stop? A log file is generated that is written to every "X seconds" with a timestamp. If it sees no entry... I could trigger a respawn – Daniel Brown Apr 10 '16 at 0:38
  • I'm granting you the bounty -- if only because you're the only user nice enough to chip in any thoughts. – Daniel Brown Apr 13 '16 at 18:17

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.