5

我有一个简单的脚本,试图让 Monit 进行监控。经过一番挖掘,我发现了这个小金块:start program = "su - myuser -c '/home/user/myscript.rb start' "我相信它应该可以工作,但查看日志文件时它说:

[PDT Oct 30 02:47:17] info     : 'simple_script' start: su
[PDT Oct 30 02:47:17] error    : Error: Could not execute su

同样,较早的尝试似乎只读取了空格之前的部分,因此:

start program = "/home/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/user/simple_script_daemon.rb stop"

结果……</p>

[PDT Oct 30 03:09:49] info     : 'simple_script' start: /home/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

它不会像第一个示例那样失败,但似乎仍然只执行空间之前的部分。

这是我的完整声明:

check process simple_script
    with pidfile /home/user/simple_script.rb.pid
    start program = "su - user -c '/home/user/simple_script_daemon.rb start' "
    stop program = "su - user -c '/home/user/simple_script_daemon.rb stop' "
    group simple_script

如果您知道可能会发生什么,我很想听听您的意见!

4

2 回答 2

7

我想您可以尝试以下方法:

check process simple_script
    with pidfile /home/user/simple_script.rb.pid
    start program = "/home/user/simple_script_daemon.rb start" as uid user and gid user
    stop program = "/home/user/simple_script_daemon.rb stop" as uid user and gid user
    group simple_script

monit doc中所述。

于 2012-01-03T15:27:02.150 回答
4

您可能需要提供完整路径su,即/bin/su

于 2012-10-02T21:38:02.870 回答