frequent-cron: always permission denied, even after chmod 777 - linux

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.

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.

Related

How to give permissions for specific commands in linux

I am new to linux. I have a build.sh file which consists of a lot of mkdir commands and some rm commands. But as I have installed this new in my VB, each time I run the .sh file, it says "Permission Denied for creating directory" and fails.
So is there any way that I grant directory privileges to all users.
Can anyone help me with this
Add "sudo" in the beginning of the directory creation command i.e
sudo mkdir dir_name
The issue might be with the directory in which the mkdir command is being run.
Use the command ll or ls -l to check the directory permissions.
If your directory doesn't have write privilege for the current user, you can run
chmod -R u+w /path/to/directory
This might require you to use sudo if permission is denied.
If you want to enable it for all users, run
chmod -R ugo+w /path/to/directory
Alternatively, a quick fix would be to run the build.sh file as root
sudo /path/to/build.sh
However, this approach is not advised unless you always run it as root

How to change permission of shellscript in databricks

I am having a shell script in the DBFS. When I am executing it, it gives permission error 13.
I tried to change the permission using 'chmod 755 name.sh'. But, no changes actually take place.
Could anyone help on the same?
Tried Code:
%cd /dbfs/FileStore/tables/
%sh chmod 775 wrapper.sh
%sh chmod +x wrapper.sh
%sh ls -ltr
-rw-r--r-- 1 root root 2819 Oct 28 12:01 wrapper.sh
Unfortunately, you cannot change permissions of files located in databricks filesystem (DBFS).
I have tried all the possibilities to change the file permissions located in dbfs and finally result in no success. Then, I have checked with product team for the solution. An d they have confirmed that, you cannot change the permissions of any files located in dbfs and asked ro run the script with following cmdlet "bash /dbfs/script.sh".
Hope this helps.

Nagios: return code of 13 is out of bounds

How can I fix that return code?
It is due to permission issue with the particular plugin. Allow nagios user to access plugin.
You can use multiple options for it as below
Give permission using ACL.
setfacl -m u:nagios:rwx /usr/lib/nagios/plugins/plugin_name.pl
Give permission (use only in test environment)
chmod 777 /usr/lib/nagios/plugins/plugin_name.pl
Change owner of the file
chown nagios /usr/lib/nagios/plugins/plugin_name.pl
cross check permission using below command
ls -l /usr/lib/nagios/plugins/plugin_name.pl
Solution that helped me:
1. sudo su -
2. cd /usr/local/nagios
3. chmod -R 755 *
4. exit
5. su - nagios
6. check any file

Permission denied for root shrc

Whenever I open the terminal on my Centos5.1, I always get this error
/root/.cshrc Permission denied
and then I can't use networking commands (ip,ifconfig,...) because they are reported as unknown commands.
Verify that you have permissions to read .cshrc To do that issue:
ls -l /root/.cshrc
If the output begins with to dashes it means that you don't. To give yourself read permission to this file issue:
chmod +r /root/.cshrc
Now if you run ls -l /root/.cshrc the output should start with -r.

ant Permission Denied problem

After extracting and saving the ant files into an opt/ directory and setting the path variable
to $ANT_HOME/bin
I ran the following command on a CentOS 5
ant -version
and I am getting the following error
-bash:/path/opt/apache-ant-1.8.2/bin/ant: Permission denied
Is there some permission I am supposed to set or some typical source of this problem?
Thanks!
If you own the file, try
chmod u+x /path/opt/apache-ant-1.8.2/bin/ant
If someone else owns it, either sudo or become root then
chmod 755 /path/opt/apache-ant-1.8.2/bin/ant
You need to have execute permissions on the file; the first gives execute permissions to the owner only and is probably preferable if you own the file and are the only one that uses it. The second requires root privileges and gives execute and read permission to everyone, plus write permission to the owner.
You can view the current permissions and ownership of the file by running ls -l /path/opt/apache-ant-1.8.2/bin/ant.

Resources