我已经安装频繁cron,根据https://github.com/homer6/frequent-cron上的安装说明。频繁cron:总是权限被拒绝,甚至后chmod 777
我已经改变了/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
它提供了以下错误:
[email protected]:~$ 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推荐:
[email protected]:~$ 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
[email protected]:~$ 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脚本的顶部:
#!/usr/bin/env python
这里找到:Crontab wont run python script
还需要但是/ usr/bin /频繁-cron的权限。
我检查了我的权限。我不确定他们是否正确。他们在我的OP,你可以检查他们吗? – RobbeM