14

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"
2
  • Not an answer to your question but you might want to look into upgrading. Security updates are a good thing.
    – Ladadadada
    Commented Aug 9, 2014 at 22:51
  • Who is user ? 2013 ?
    – krisFR
    Commented Aug 9, 2014 at 23:39

3 Answers 3

8

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.

2
  • 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
    Commented Nov 28, 2014 at 10:30
  • 3
    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
    Commented Feb 16, 2016 at 14:39
7

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.

3

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

You must log in to answer this question.

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