简体   繁体   English

以非 root 用户身份监控运行脚本,获得“权限被拒绝”

[英]Monit running script as non-root user getting "permission denied"

I am using Monit to ensure one of my applications is always running.我正在使用 Monit 来确保我的一个应用程序始终在运行。 Monit runs as root but my goal is to run the application as "myuser" and not as root. Monit 以 root 身份运行,但我的目标是以“myuser”而不是 root 身份运行应用程序。 So I use the following configuration:所以我使用以下配置:

check process myprocess with pidfile "/home/myuser/monitoring/myprocess.pid"
    start program = "/home/myuser/scripts/myprocess.sh start"
    as uid 1000 and gid 1000
    stop program = "/home/myuser/scripts/myprocess.sh stop"
    as uid 1000 and gid 1000

Now when I login as myuser, navigate to "/home/myuser/scripts" and run ./myprocess.sh start , the application starts with no issues.现在,当我以 myuser 身份登录时,导航到"/home/myuser/scripts"并运行 ./myprocess.sh start ,应用程序将毫无问题地启动。

However when I let monit do it, the program does not start and logs show permission denied for a mkdir function in the sh file.但是,当我让 monit 执行此操作时,程序不会启动,并且日志显示 sh 文件中mkdir函数的permission denied

Isn't monit supposed to run it just like I would from shell since I specified uid and gid 1000 (which I got from the shell command id )?因为我指定了 uid 和 gid 1000 (我从 shell 命令id获得),monit 不应该像我从 shell 一样运行它吗? Did I miss anything in my configuration?我错过了配置中的任何内容吗?

我有同样的错误,并通过在我试图在脚本中修改的文件/目录中指定绝对路径来修复它。

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

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