You are not logged in.

#1 2010-07-19 10:56:16

jaloz
Member
Registered: 2008-11-18
Posts: 25

Crontab -e not working

I'm trying to create a crontab as a regular user and it's not working.

I type "crontab -e" and vim starts with a blank file called /var/tmp/crontab.something
I add the cron entry I want, save and exit.
I type "crontab -e" again and I'm looking at an empty file again sad

I'm in the "users" group.
/usr/bin/crontab is owned by root:users.
crond (dcron) is running and system crontabs are executed.

Any ideas?

Offline

#2 2010-07-19 11:03:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Crontab -e not working

'sudo crontab -e'?

Offline

#3 2010-07-19 11:10:15

jaloz
Member
Registered: 2008-11-18
Posts: 25

Re: Crontab -e not working

karol wrote:

'sudo crontab -e'?

... brings up root's crontab and the same behaviour occurs. If I edit and save it, my changes simply vanish.

Offline

#4 2010-07-19 11:11:41

tlvince
Member
Registered: 2010-07-06
Posts: 68
Website

Re: Crontab -e not working

Add yourself to the cron group?

Gentoo Wiki wrote:

No matter which cron package you use, if you want to allow a user to use crontab, he will first have to be in the cron group.

Last edited by tlvince (2010-07-20 11:02:44)

Offline

#5 2010-07-19 11:11:49

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Crontab -e not working

'sudo crontab -e -u karol'
From 'man crontab': Only users who belong to the same group as the crontab binary will be able to install or edit crontabs.

Last edited by karol (2010-07-19 11:12:56)

Offline

#6 2010-07-19 11:15:45

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Crontab -e not working

Are you sure that the temp file is in /var/tmp/ ?
Because mine goes to /tmp/

This might sound stupid but I just saw this in the wiki:

Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is users, of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:

# gpasswd -a username users

neutral

Offline

#7 2010-07-19 11:20:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Crontab -e not working

@ sand_man
That is consistent with my understanding of this issue.
I can edit and the files doesn't disappear, stays as /tmp/crontab.kj7ngJ atm. It's still a tempfile, but it doesn't exhibit OPs problem

jaloz wrote:

I type "crontab -e" again and I'm looking at an empty file again

Offline

#8 2010-07-19 11:33:33

jaloz
Member
Registered: 2008-11-18
Posts: 25

Re: Crontab -e not working

tlvince wrote:

Add yourself to the cron group.

Gentoo Wiki wrote:

No matter which cron package you use, if you want to allow a user to use crontab, he will first have to be in the cron group.

There is no cron group and surely that wouldn't apply to root.

karol wrote:

'sudo crontab -e -u karol'
From 'man crontab': Only users who belong to the same group as the crontab binary will be able to install or edit crontabs.

That doesn't work either and as I said in the initial post, /usr/bin/crontab is owned by root:users.

sand_man wrote:

Are you sure that the temp file is in /var/tmp/ ?
Because mine goes to /tmp/

Definitely /var/tmp here.

Where do regular user crontab files go ordinarily? $HOME/.crontab? Maybe I could just create it manually and side-step this problem for now.

Offline

#9 2010-07-19 11:47:46

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Crontab -e not working

No they go in /var/spool/cron/
You don't need to be in the "cron" group. As you said, it doesn't exist. Gentoo != Arch.
What is the output of `groups`


neutral

Offline

#10 2010-07-19 11:54:34

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Crontab -e not working

Again, from the manpage: "The superuser also has his or her own per-user crontab, saved as /var/spool/cron/root."

[karol@black ~]$ l /var/spool/cron/
total 8,0K
-rw------- 1  68 07-19 13:28 karol
-rw------- 1 513 07-19 13:22 root

Which cron are you using:

[karol@black ~]$ pacman -Ss cron
core/dcron 4.4-2 [0,03 MB] (base) [installed]
    dillon's lightweight cron daemon
extra/kdeadmin-kcron 4.4.5-1 [0,20 MB] (kde kdeadmin)
    Configure and schedule tasks
community/adns 1.4-2 [0,08 MB]
    adns is an asyncronous replacement resolver library
community/fcron 3.0.6-3 [0,13 MB]
    feature-rich cron implementation
community/gnome-schedule 2.1.1-1 [1,16 MB]
    GNOME frontend to cron and at
community/incron 0.5.9-1 [0,11 MB]
    Like the regular cron but is driven by filesystem events instead of time periods
community/perl-datetime-cron-simple 0.2-4 [0,00 MB]
    Perl/CPAN Module DateTime::Cron::Simple
community/wtf 20071004-2 [0,01 MB]
    ancronym dictionary

Offline

#11 2010-07-19 11:59:38

jaloz
Member
Registered: 2008-11-18
Posts: 25

Re: Crontab -e not working

sand_man wrote:

What is the output of `groups`

lp wheel mpd video audio users vboxusers

@karol it's dcron

Well, I created a .crontab in my home directory, crossed my fingers and typed

crontab -l

... nothing - and not easy to type with crossed fingers wink
So then I tried

crontab .crontab

to replace the contents of my crontab with a file as the man page says you can do. Whaddaya know - it worked.

Thanks for all the replies. I'd like to know what's going on but for now at least I've found a way around it.

Offline

#12 2010-07-19 13:29:23

jaloz
Member
Registered: 2008-11-18
Posts: 25

Re: Crontab -e not working

UPDATE

I just had to know what was causing this and after stabbing around in the dark for a while I tried

EDITOR=/usr/bin/nano crontab -e

and things worked as they should.

So the problem seems to be related to vim. Weird.

Offline

#13 2010-07-19 14:03:53

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: Crontab -e not working

jaloz wrote:

UPDATE

I just had to know what was causing this and after stabbing around in the dark for a while I tried

EDITOR=/usr/bin/nano crontab -e

and things worked as they should.

So the problem seems to be related to vim. Weird.

I had some problems with crontab awhile back and it was due to vi not vim. The default editor was vi and (I cannot remember exactly now) think it had some issue with my CLI  environment.
The simple solution I gave it was to use vim by editing my .bashrc and adding an alias like so: alias vi='vim'

From there on vim was used and problem solved.

Hope this may be of help too.

R.

Offline

#14 2010-07-19 14:52:48

jaloz
Member
Registered: 2008-11-18
Posts: 25

Re: Crontab -e not working

ralvez wrote:

I had some problems with crontab awhile back and it was due to vi not vim. The default editor was vi and (I cannot remember exactly now) think it had some issue with my CLI  environment.
The simple solution I gave it was to use vim by editing my .bashrc and adding an alias like so: alias vi='vim'

From there on vim was used and problem solved.

Hope this may be of help too.

R.

Thank you. Based on your post I tried some things with aliases which didn't help and then installed vi and it started working. I don't understand this at all but I know to keep vi installed now.

Can someone confirm this behaviour? I don't think I've done anything odd to my system to cause this. Might be a bug.

Last edited by jaloz (2010-07-19 14:53:37)

Offline

#15 2010-07-19 21:33:56

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: Crontab -e not working

It may be a bug (I do not know for sure) but ... it may be not. Like I said, vi is the default editor for crontab, so may be your problems stated because you did not have it in the first place.
In my case I did have vi but it was causing me grief so I aliased it to vim and it worked fine after that.

R.

Offline

#16 2012-03-05 01:57:56

maput
Member
Registered: 2012-02-29
Posts: 7

Re: Crontab -e not working

i got same problem too..
836_2012_03_05_084614_tn.jpg

any idea?
i change to nano in bash.bashrc

its working now:D

Last edited by maput (2012-03-05 04:58:00)

Offline

Board footer

Powered by FluxBB