Updating crontab using the crontab -e command (vim)

ShaunHH

New Member
Hi All,
I've got a question for any linux gurus out there...

I've never been able to edit my crontab file using the standard crontab -e command.

What happens is that when I issue the crontab -e command the crontab file gets loaded into vim, but when I save and exit I get the following message in vim:

"/mnt/hd2/mod/var/spool/cron/crontabs.4569" 30L, 1032C written
E138: Can't write viminfo file /.viminfo!

then when I close vim, the crontab file doesn't get updated.
I'm guessing that it's trying to write a .viminfo file into the read-only part of the system but don't know how I can change the setting for this.
I've had this issue for a long time, but have always got around it by simply copying an updated crontab into /mod/var/spool/cron/crontabs/root directory
Then the crontab updates fine (and shown by doing a crontab -l command).

Any ideas on this? Would be nice to do it the proper way intead of uding the workaround... :)
 

MymsMan

Ad detector
I never ever use vim - a tool designed by masochists for use by masochists

I just go into file editor from the webif diagnostics page and select crontab from the list of frequently edited files, make my changes and save
 

/df

Well-Known Member
In OP's case it looks like vim is installed but not working. It saves the temporary file /mod/var/spool/cron/crontabs.nnnnn, then fails to save its history file /.viminfo, so that crontab thinks the edit failed and discards the temporary file.

If vim works directly from the telnet command-line, this is a result of some initialisation not having set HOME, or the ~ not being parsed in ~/.viminfo, when crontab runs vim.

crontab -e uses the VISUAL and EDITOR environment variables to find an editor, apparently defaulting to vi in the CF package.

A work-around is to uninstall vim and use BusyBox vi instead, which works for me with VISUAL=vi having been set automatically.

I guess that vim has installed a script that overrides VISUAL=vi in /mod/etc/profile.d, so you could also try editing that to stop it from doing so.

Finally, you could try forcing vim to save its history file in the right place using the -i ... option (search "man vim").
 
OP
S

ShaunHH

New Member
I never ever use vim - a tool designed by masochists for use by masochists
LOL - fair point :)

I just go into file editor from the webif diagnostics page and select crontab from the list of frequently edited files, make my changes and save
It's strange - this never really occured to me... handy!
 
OP
S

ShaunHH

New Member
If vim works directly from the telnet command-line, this is a result of some initialisation not having set HOME, or the ~ not being parsed in ~/.viminfo, when crontab runs vim.

crontab -e uses the VISUAL and EDITOR environment variables to find an editor, apparently defaulting to vi in the CF package.

A work-around is to uninstall vim and use BusyBox vi instead, which works for me with VISUAL=vi having been set automatically.

I guess that vim has installed a script that overrides VISUAL=vi in /mod/etc/profile.d, so you could also try editing that to stop it from doing so.

Finally, you could try forcing vim to save its history file in the right place using the -i ... option (search "man vim").
thanks - a couple of areas to investigate there :thumbsup:
 
Top