-1

I've installed frequent-cron, according to the installation instructions on https://github.com/homer6/frequent-cron.

I've changed /etc/init.d/frequent_service/init_script.tpl for my own needs:

# 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

But when I want to start frequent-cron with:

sudo /etc/init.d/frequent_service start

It gives these errors:

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.

Even after:

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

It gives the same errors.

I think I can split this problem in 2 problems.

1) Error about the python script:

I don't know what's wrong because it runs fine in a normal cronjob. Is there anything wrong with how I want to start the script in init_script.tpl?

2) Error Permission denied:

I always thought chmod -R 777 gives the folder + all subfolders and files ALL permissions? So why permission is still denied?

Edit: Checked the permissions as exussum recommended:

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

Are these correct? Or, should these permissions be enough?

Edit 2: Answer to problem 1 (python)

Had to put the following line on top of the python script:

#!/usr/bin/env python

Found here: Crontab wont run python script

Still need permissions for /usr/bin/frequent-cron though.

Community
  • 1
  • 1
RobbeM
  • 727
  • 7
  • 16
  • 36

1 Answers1

0

It's likely you don't have permission (x) on one of the paths leading to it.

namei -m /your/path/here

will show all permissions of the path to that point.

Edit

On second look looks like your missing a shebang line

#!/usr/bin/python

at the top of the file.

Armali
  • 18,255
  • 14
  • 57
  • 171
exussum
  • 18,275
  • 8
  • 32
  • 65
  • I've checked my permissions. I'm not sure if they are correct. They are in my OP, can you check them please? – RobbeM Sep 09 '15 at 11:01