Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As a regular user I can't edit my cron settings. I get a "permission denied" for everything: listing the cron commands or editing them.

Example:

cron -l
cron: can't open or create /var/run/crond.pid: Permission denied

crontab -e
/var/spool/cron/crontabs/skerit: Permission denied

These are the permissions of /var/run/crond.pid:

-rwxr-Sr-- 1 root root 5 2011-05-27 12:44 crond.pid
---------- 1 root root 0 2011-03-23 21:13 crond.reboot

And the permissions of /var/spool/cron/:

drwxr-sr-x  5 root root     4,0K 2009-12-23 23:01 cron

All users are also added to the /etc/groups file:

crontab:x:102:skerit,www-data
share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

This was a messy problem.

I ended up adding all the users to the crontab group, and setting the group ownership of all needed files to that crontab group.

A lot of permissions were messed up. Changing the group ownership to something else first "resets" those permissions.

The crontab executable:
sudo chgrp crontab /usr/bin/crontab
sudo chmod g+s /usr/bin/crontab
Result: -rwxrwsr-x 1 root crontab 37K 2010-04-15 08:51 /usr/bin/crontab

The cron spool files:
sudo chmod 4774 -R /var/spool/cron
Result: drwsrwsr-- 5 root crontab 4,0K 2009-12-23 23:01 cron

The cron files in these spool directories need to be READ AND WRITE only. Otherwise they won't run. sudo chmod 600 /var/spool/cron/crontabs/*

The cron pid file:
sudo chmod 744 /var/run/crond.pid

I think that should cover it.

share|improve this answer
    
I also needed to chmod -R g+s /var/spool/cron to achieve the result as shown. –  fsb Oct 28 '11 at 15:28
add comment

What linux distro is this? Is there an /etc/cron.allow or /etc/cron.deny file? If so, what are their contents?

What are the permissions on /var/spool/cron/crontabs/skerit

Any user should be able to edit their own crontab.

share|improve this answer
    
I had a ton of problems. The permissions on the skerit file in crontabs was, indeed, wrong. But the permission of the spool directories and the crontab executable were also wrong. I fixed it now –  skerit May 27 '11 at 12:07
add comment

The permissions for the CRON files are set to user root group root, so you'll need to be root to modify or run CRON files. Alternatively you can log in as root and change the groups to something else so you can edit it.

share|improve this answer
    
Oh, really? Shouldn't it be solved then by setting the group ownership to crontab, which my users are members of? (Which also does not work) –  skerit May 27 '11 at 11:11
    
Only if the files are owned by the crontab group, the snippets you posted show it being owned by the 'root' group. –  sam May 27 '11 at 11:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.