简体   繁体   English

在upstart .conf脚本中运行bash脚本

[英]Running bash script in upstart .conf script

I would like run my bash script (kvm_manage) in startup, and it doesnt work. 我想在启动时运行我的bash脚本(kvm_manage),它不起作用。 Here is my upstart .conf script: 这是我的upstart .conf脚本:

      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". 我想用参数“start”运行它。 It is possible? 有可能的? What should I change? 我应该改变什么?

thanks for help 感谢帮助

Running a command via exec with arguments is fine - see http://upstart.ubuntu.com/wiki/Stanzas#exec which gives such an example. 通过带有参数的exec运行命令很好 - 请参阅http://upstart.ubuntu.com/wiki/Stanzas#exec ,它给出了这样的示例。

However, upstart will use /bin/sh not bash , so if your script needs bash you'd need something like 但是,upstart会使用/bin/sh而不是bash ,所以如果你的脚本需要bash,你需要类似的东西

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: 更新:另请参阅Guss评论中的建议,以便在简单情况下使用exec节:

exec bash -c '/etc/kvm_manage start'

Or if kvm_manage is an executable with a she-bang ( #!/bin/bash ), then simply: 或者,如果kvm_manage是一个带有she-bang( #!/bin/bash )的可执行文件,那么只需:

exec /etc/kvm_manage start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM