incrond 文件产品的所有者?
请[1]考虑此命令:sudo incrontab ~/incron-config
,其中~/incron-config
包含:
/home/zetah/doc IN_CREATE,IN_MOVED_TO /home/zetah/scripts/do_something.sh $@/$#
并且do_something.sh
由以下内容组成[2]:
#! /bin/bash
python /home/zetah/scripts/py_something.py "$1"
Python脚本访问一些在线服务并生成3个新文件。它们属于root
。
为什么会这样以及我该如何改变这种行为。我想成为这些产品文件的所有者,
谢谢
[1] 发布在 Ask Ubuntu 上 - 想在这里尝试一下机会,将在任何结果中相互链接
[2] 将 Python 脚本包装在 Bash 脚本中似乎很蹩脚,但我无法做到这一点
Please [1] consider this command: sudo incrontab ~/incron-config
where ~/incron-config
contains:
/home/zetah/doc IN_CREATE,IN_MOVED_TO /home/zetah/scripts/do_something.sh $@/$#
and do_something.sh
consists of [2]:
#! /bin/bash
python /home/zetah/scripts/py_something.py "$1"
Python script accesses some online services and produces 3 new files. They are owned by root
.
Why is that and how can I change this behavior. I want to be the owner of those product files
Thanks
[1] Posted on Ask Ubuntu previous - thought to try my chances here, will interlink in any result
[2] Seems lame to wrap Python script in Bash script, but I couldn't do it otherwise
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建的文件由root拥有,可能是因为您以root身份运行incrontab,然后python通过bash继承它
您可以从您自己的用户运行incrontab,只需在/etc/incron.allow中添加您的用户名(以允许您使用incron)并然后使用您的帐户使用“incrontab -e”重新创建 incron 表(不要忘记从 root 中删除该条目)
第二个选项(如果您无法修改 incron.allow)是使用您的用户名调用 python。
在您的 bash 脚本中,修改:
希望对
有帮助
ericc
created files are owned by root probably because you run incrontab as root and then python inherit from it through bash
You can run incrontab from your own user, simply add your username in /etc/incron.allow (to allow you to use incron) and then recreate the incron table with your account with "incrontab -e" (don't forget to remove the entry from root)
Second option (if you can't modify incron.allow) is to call python with your username.
In your bash script, modify :
in
Hope it's help
ericc