I have been tasked to run a script from cron, so I have written following cronjob for the script and it output the following mentioned error message.
cronjob
#BE housekeeper.sh
* * * * * /product/tools/housekeeper.sh -t BE > /tmp/fileset.out 2>&1
fileset.out contain the error message. this is the error message.
/bin/sh: /product/tools/housekeeper.sh: Permission denied
why does it says permission denied. user1 can execute the housekeeper script as follows
$sh housekeeper.sh -t BE
then I checked whether user1 is allowed to run the cronjob. this check also pass. user1 is allowed to run crontab. so what could be the possible error in this case.
root 4181 1 0 2011 ? 00:00:00 crond
user1 7648 7564 0 06:18 pts/0 00:00:00 grep cron
I checked execute rights of the application
$ls -ltr
-rw-r----- 1 user1 aapp 11732 May 17 08:55 housekeeper.sh
does it says this application is executable
thanks in advance for anyhelp
You need to change
housekeeper.shto have755permission (executable)Running
sh housekeeper.shand/product/tools/housekeeper.shhas a slightly difference in the way that doingshcalls an executable calledshfound in the$PATHand feedhousekeeper.shinto it, so you only need read permission onhousekeeper.sh, but directly running it by doing/product/tools/housekeeper.shwould require you to have execute permission (thus the755)EDIT
I see that you have
-rw-r-----permission, that is quite simply610, let me explain a bita file has 3 sets of permissions, represented in 3 groups of 3 bits. The first bit means read permission, as in your output, you see
r, second bit is write permissionwand third bit (which is not set, isx, executable bit). You have 3 sets of that, the first for Owner, Group and then Other, thus you have 9 bitsso
rw-r-----indicates that the owner has read and write bit, group has read bit, and other has no permission to do anything to this file.Setting 755 will yield
rwxr-xr-x, I’ll leave it to you to think why 😀