Linux – Cron: Permission denied on everything

cronlinuxpermissions

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

Best Answer

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.