Operating System - Linux
1753816 Members
8448 Online
108805 Solutions
New Discussion юеВ

Re: Crontab not accepting changes

 
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

I have found a possible cause for this but have not yet found a fix. The problem is with VIM and the way it handles tmp files I ran a stat and posted the results below. The way the stat should look. The Inodes should be the same after the w: and the modify and change times should be different than the access time.

Just After the file was opened:
File: "/tmp/crontab.6550"
Size: 2463 Blocks: 8 IO Block: -4611708214818369536 Regular File
Device: 803h/2051d Inode: 24 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: Fri Dec 12 10:48:18 2008
Modify: Fri Dec 12 10:48:18 2008
Change: Fri Dec 12 10:48:18 2008

After edit and :w to tmp file:
File: "/tmp/crontab.6550"
Size: 2478 Blocks: 8 IO Block: -4611721408957902848 Regular File
Device: 803h/2051d Inode: 24 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: Fri Dec 12 10:48:18 2008
Modify: Fri Dec 12 10:48:43 2008
Change: Fri Dec 12 10:48:43 2008


The problem I am having with the VIM editor.
Vim is creating a new tmp file with every write or save
Which causes the access, modify, and change times to be the same

File: "/tmp/crontab.18352"
Size: 3079 Blocks: 8 IO Block: -4611692890375057408 Regular File
Device: 805h/2053d Inode: 7209236 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: Fri Dec 12 10:19:28 2008
Modify: Fri Dec 12 10:19:28 2008
Change: Fri Dec 12 10:19:28 2008

After the w: on the tmp file:
File: "/tmp/crontab.18352"
Size: 3094 Blocks: 8 IO Block: -4611692890375057408 Regular File
Device: 805h/2053d Inode: 7209239 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: Fri Dec 12 10:19:56 2008
Modify: Fri Dec 12 10:19:56 2008
Change: Fri Dec 12 10:19:56 2008

If anyone has or knows of a way to correct this please advise
Dennis Handly
Acclaimed Contributor

Re: Crontab not accepting changes

>The problem is with VIM and the way it handles tmp files

Why do you think this has anything to do with crontab?

>Vim is creating a new tmp file with every write or save, which causes the access, modify, and change times to be the same

What's wrong with that?
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

When using crontab -e if the change time is not different from the access time then the temp file is not written back to the original crontab file. This is shown in my previous posting of the stat that I ran on a working server compared to the non working. What I am looking for is a way to get vim to not create a new temp file every time a w or wq is initiated.
Dennis Handly
Acclaimed Contributor

Re: Crontab not accepting changes

>When using crontab -e if the change time is not different from the access time then the temp file is not written back to the original crontab file.

This doesn't make sense. It should compare the modification time with the previous modification time, when it wrote it. But I suppose it doesn't like the fact that the inode has changed?

>This is shown in my previous posting of the stat that I ran on a working server compared to the non working.

That's a compelling argument.

>What I am looking for is a way to get vim to not create a new temp file every time a w or wq is initiated.

I'm not sure why it would do that? In the meantime, could you do the following:
:w
:touch %
:q

That way your modification time should be different from the inode change time.
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

The cause of the problem has been located. My /tmp directory is a symlink to another partition with more space which apparently due to the way vim handles files causes crontab -e to not work properly. /tmp must be an actual directory and not a symlink I have tested this and the problem of not saving the crontab went away when /tmp was an actual directory.

Thanks for all your help guys and the link below is where I found the answer to the problem.

http://bugs.gentoo.org/32938
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

Solution listed in previous post