11

I would like run my bash script (kvm_manage) in startup, and it doesnt work. Here is my upstart .conf script:

      description "kvm start skript"

      start on local-filesystem
      stop on shutdown

      respawn 

      script
         exec /etc/kvm_manage start
      end script

I want run it with argument "start". It is possible? What should I change?

thanks for help

1 Answer 1

18

Running a command via exec with arguments is fine - see http://upstart.ubuntu.com/wiki/Stanzas#exec which gives such an example.

However, upstart will use /bin/sh not bash, so if your script needs bash you'd need something like

script
    exec bash -c '/etc/kvm_manage start'
end script

Update: See also the suggestion in the comments from Guss to use the exec stanza instead for simple cases:

exec bash -c '/etc/kvm_manage start'

Or if kvm_manage is an executable with a she-bang (#!/bin/bash), then simply:

exec /etc/kvm_manage start
Sign up to request clarification or add additional context in comments.

1 Comment

script is used for running multiple commands, I think in this case its better to use the exec stanza instead. Its actually quite similar to the above example: just drop the script parts and leave only exec bash -c '/etc/kvm_manage start'. Also, if kvm_manage is an executable with a she-bang, then you don't even need that, just use exec /etc/kvm_manage start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.