12

Recently, a job configured to run from a user's crontab stopped executing. When attempting to list or edit the crontab for the user, the result is:

user@host:~$ crontab -l
crontabs/user/: fopen: Permission denied

user@host:~$ crontab -e
crontabs/user/: fdopen: Permission denied

Clearly it is permissions related, though I'm not sure how the permissions got changed -- and more importantly, what they should be set to.

Permissions on /usr/bin/crontab:

$ ll /usr/bin/crontab
-rwxr-sr-x 1 root libuuid 35896 Aug 24  2010 /usr/bin/crontab*

Permissions on /var/spool/cron/crontab directory:

# ll /var/spool/cron/
total 12
drwxr-xr-x 3 root root    4096 Oct 12  2010 ./
drwxr-xr-x 7 root root    4096 Jun  5 20:51 ../
drwx-wx--T 2 root libuuid 4096 Jan 10  2014 crontabs/

Permissions inside crontab directory:

# ll /var/spool/cron/crontabs/
total 16
drwx-wx--T 2 root libuuid 4096 Jan 10  2014 ./
drwxr-xr-x 3 root root    4096 Oct 12  2010 ../
-rw------- 1 1017 libuuid 1120 Dec  3  2013 
-rw------- 1 root libuuid 1342 Jan 10  2014 root

Distro info:

# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"
  • Not an answer to your question but you might want to look into upgrading. Security updates are a good thing. – Ladadadada Aug 9 '14 at 22:51
  • Who is user ? 2013 ? – krisFR Aug 9 '14 at 23:39
7

The permissions on /usr/bin/crontab should be:

 owner=root
 group=root
 perms= 4755  (rws rx rx)

Your /usr/bin/crontab has the wrong group owner. Additionally, it has sgid and NOT suid which it must have.

| improve this answer | |
  • 1
    Is there any reason why the defaults wouldn't be what you wrote? I haven't touched my permissions (Ubuntu 14.04), and I have -rwxr-sr-x 1 root crontab 35984 Feb 9 2013 /usr/bin/crontab. – Gauthier Nov 28 '14 at 10:30
  • 2
    I ran into this issue after deleting a recreating a user with a different UID - this fixed it for me: askubuntu.com/questions/710671/… – ryantuck Feb 16 '16 at 14:39
5

You can edit your user crontab if you have superuser access, without modifying permissions:

$ sudo crontab -u username -e

I thought you could edit your user crontab without sudo, but I get the same permission issues as you, even after adding myself to the crontab group. The permissions in my user's crontab (/var/spool/cron/crontabs) are -rw-------, group is crontab.

| improve this answer | |
0

I encountered the same error. The issue was on directory /var/spool/cron/crontabs

$ sudo stat /var/spool/cron/crontabs
  Fichier : '/var/spool/cron/crontabs'
   Taille : 34          Blocs : 0          Blocs d'E/S : 4096   répertoire
Périphérique : 802h/2050d   Inœud : 272986341   Liens : 2
Accès : (1730/drwx-wx--T)  UID : (    0/    root)   GID : (  107/ crontab)
Accès : 2020-07-10 14:01:01.246597775 +0200
Modif. : 2020-07-10 14:01:00.806605868 +0200
Changt : 2020-07-10 14:01:00.806605868 +0200
  Créé : -

If you have different permission / owner / group, you can fix it like this :

sudo chmod 1730 /var/spool/cron/crontabs
sudo chown root:crontab /var/spool/cron/crontabs
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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