frequent-cron:即使在chmod 777之后,也始终被拒绝

时间:2015-09-09 10:55:06

标签: linux permissions cron chmod

我根据https://github.com/homer6/frequent-cron上的安装说明安装了frequency-cron。

我已根据自己的需要更改了/etc/init.d/frequent_service/init_script.tpl:

# This is arbitrary. Change it to whatever you'd like.
SERVICE_NAME="frequent_service"

# Frequent cron must exist at this path. Optionally, you can change it to a path where it does exist.
EXEC=/usr/bin/frequent-cron

# Change this to the path of your choice.
#PIDFILE=/var/run/${SERVICE_NAME}.pid
PIDFILE=/var/run/${Odoo_OPC}.pid

# Point this to the shell (or program) that you'd like to run. /tmp/myshell.sh is just an example.
#COMMAND=/tmp/myshell.sh
COMMAND=python /usr/bin/OPCConnectie/OdooNaarOPC.py

# Frequency is in milliseconds. The command will be invoked every frequency interval.
FREQUENCY=1000

但是,当我想开始频繁使用cron时:

sudo /etc/init.d/frequent_service start

它给出了这些错误:

hew@hew-VirtualBox:~$ sudo /etc/init.d/frequent_service start
/usr/bin/OPCConnectie/OdooNaarOPC.py: 1: /usr/bin/OPCConnectie/OdooNaarOPC.py: import: not found
/usr/bin/OPCConnectie/OdooNaarOPC.py: 2: /usr/bin/OPCConnectie/OdooNaarOPC.py: Syntax error: "(" unexpected
Starting frequent_service frequent cron...
/etc/init.d/frequent_service: 32: /etc/init.d/frequent_service: /usr/bin/frequent-cron: Permission denied
frequent_service started.

即便:

sudo chmod -R 777 /usr/bin/OPCConnectie/
sudo chmod -R 777 /etc/init.d/frequent_service

它会出现同样的错误。

我想我可以在2个问题中分解这个问题。

1)关于python脚本的错误:

我不知道什么是错的,因为它在正常的cronjob中运行良好。 我想如何在init_script.tpl中启动脚本有什么问题吗?

2)错误权限被拒绝:

我一直认为chmod -R 777给出了文件夹+所有子文件夹和文件的所有权限?那么为什么仍然拒绝许可?

编辑:检查权限为推荐的exussum:

hew@hew-VirtualBox:~$ namei -m /etc/init.d/frequent_service
f: /etc/init.d/frequent_service
 drwxr-xr-x /
 drwxr-xr-x etc
 drwxr-xr-x init.d
 -rwxrwxrwx frequent_service
hew@hew-VirtualBox:~$ namei -m /usr/bin/OPCConnectie/
f: /usr/bin/OPCConnectie/
 drwxr-xr-x /
 drwxr-xr-x usr
 drwxr-xr-x bin
 drwxrwxrwx OPCConnectie

这些是正确的吗?或者,这些权限应该足够吗?

编辑2:回答问题1(python)

必须将以下行放在python脚本之上:

#!/usr/bin/env python

在此处找到:Crontab wont run python script

仍然需要/ usr / bin / frequent-cron的权限。

0 个答案:

没有答案
相关问题