当 incrond 作为服务运行时,用户的 incrontab 不起作用(仅 root 的)

Ant*_*ard 6 openrc incron

这是我的 incrontab (托尼的 incrontab):

/home/tony/Workspace/cocoonr/ui/static/ui/img/icons/vector IN_MODIFY,IN_CREATE,IN_MOVED_TO /bin/sh /home/tony/Workspace/cocoonr/boilerplate/svg2djangohtml $@/$# /home/tony/Workspace/cocoonr/ui/templates/inc/icons/
Run Code Online (Sandbox Code Playgroud)

我多次测试了它,改变了一些东西,当 incrond 作为服务运行时(使用 openrc),无法使其工作。

如果我在前台运行 incrond ( incrond -n),那么 Tony 的 incrontab 就可以工作

如果我将 root 的 incrontab 设置为上面给出的值,即使作为服务运行它也可以工作。

我的托尼在/etc/incron.allow

root
tony
Run Code Online (Sandbox Code Playgroud)

并且没有/etc/incron.deny

我什至尝试使用更简单的 incrontab:

/tmp/foo IN_ATTRIB touch /tmp/bar
Run Code Online (Sandbox Code Playgroud)

结果是一样的。

如何让用户的incrontab工作?

小智 1

如果 incrontab 的二进制文件(我不知道,从未使用过它)没有设置他的 SGID 位,则可能会导致这种奇怪的行为。

设置它chmod g+s /path/to/binary(/usr/bin/incrontab,也许?)

您可以评估它是否是通过以下方式设置的:

ls -l /path/to/binary

(例子)

ls -l /usr/bin/crontab
-rwxr-s--x 1 root crontab 44336 Jun 23 18:47 /usr/bin/crontab
Run Code Online (Sandbox Code Playgroud)