user75472
user75472

Reputation: 1295

How to give permission for the cron job file?

I have set the cron tab for my site. But I have got message in my mailing id like this "Permission denied" for the script. Can anyone help me telling what may be the problem.

Thanks......

Upvotes: 6

Views: 91776

Answers (4)

Mad
Mad

Reputation: 1

$sudo -i
$adduser your-user crontab

Upvotes: 0

matt2000
matt2000

Reputation: 1073

I ran into this issue today and was baffled until I realized that the denied commands were SSH commands. I had forgotten that I was connecting with an SSH key that required a passphrase, so the real issue had nothing to do with cron in my case.

My solution was to create an additional key for this script with no passphrase (using ssh-keygen), install it on the remote server, and specify it in the script with the -i flag to the ssh commands.

ssh -i /path/to/id_rsa.no-passphrase user@remote command-to-run

Upvotes: 4

ravi
ravi

Reputation: 41

friends if any one wants schedule crons from other user just do this

root user:-

ls /usr/bin/crontab
chmod 4755 /usr/bin/crontab

echo PATH
vi /etc/crontab

SHELL=/bin/bash
PATH=/usr/java/jdk1.5.0_22/bin:/root/bin:/usr/java/jdk1.5.0_22/bin:/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
MAILTO=root
HOME=/

cd /etc/cron.d

create cron.allow file if not exist

vi cron.allow
root
other username

save and exist

su – username
/usr/bin/crontab -e

schedule here ……………….

Upvotes: 4

Colin Pickard
Colin Pickard

Reputation: 46663

You get this error while setting the crontab? or from a script running from the cron?

If while setting the crontab, try this:

You type: crontab -e You get: -bash: /usr/bin/crontab: Permission denied

Problem: Your user is not in the cron group.

Solution: As root, edit the /etc/group file, find the cron group and add your user to that line (the usernames are comma-separated). Then re-login as your user.

Verify: Run command "groups". You should see "cron" in there.

(from http://www.parseerror.com/argh/crontab-e-Permission-denied.txt)

Upvotes: 10

Related Questions