How to give permission for the cron job file?

做~自己de王妃 提交于 2019-12-23 21:29:04

问题


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......


回答1:


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)




回答2:


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 ……………….




回答3:


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


来源:https://stackoverflow.com/questions/892104/how-to-give-permission-for-the-cron-job-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!