13

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

3 Answers 3

6

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.

1
  • I also needed to chmod -R g+s /var/spool/cron to achieve the result as shown.
    – user29502
    Oct 28, 2011 at 15:28
1

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.

2
  • 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) May 27, 2011 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.
    – user80776
    May 27, 2011 at 11:18
1

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.

1
  • 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 May 27, 2011 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .