Editing a CRON file

Hi,

I am accessing CRON via telnet and want to set up some jobs. I have typed crontab -e to edit my cronfile but I can't seem to enter anything when I type on my keyboard. All I have is a flashing cursor at the top with ~ on the start of each line.

How can I enter the jobs and save this file? Thanks for any help

Regards,

Jaffy

when you edit a cron file using crontab -e

crontab use vi editor, to start typing hit the Esc key on your keyboard followed by i key to insert then you could start typing

to save hit the Esc key on your keyboard, then semi colom i.e :
followed by wq

here the editor is decided by the EDITOR environment variable. the default is ed. you can set it to vi and then make the changes as mentioned above

try this,

do a crontab -l
copy and paste all content to a new file
then using vi or any other editor, edit the new file to add jobs.
save changes and then run this command to submit this file to your crontab

#crontab newfilename

to confirm do a crontab -l

hope this works for you

HI,
crontab -e is working fine if i do set the variable EDITOR=vi first.

I would say that directly editing the crontab file is dangerous!

Holistic is close to my suggestion. You can do the following commands. I keep a copy of my root crontab for safe keeping.

crontab -l > tempcron # saves crontab to a file
vi tempcron # edit crontab file safely!!
crontab tempcron reapply changes to crontab with config file.

This is a foolproof way to modify the crontab. Sometimes if you get control chars in the crontab it may corrupt it.

Always use vi and edit using another file.

:smiley:

It sounds like the OP is getting dropped into vi, and doesn't know what to do from there.

Search for a vi reference or tutorial - that'll help.

And there nothing wrong with using the crontab command, as long as you're aware of what you're doing. You could just as easily replace the entire crontab incorrectly using "crontab filename" as you could making an error in vi / ed / whatever and saving before you exit.

Thanks for the clarification LivinFree.

Okay, maybe it is not absolutely foolproof, but it is somewhat foolproof. In a corporate setting, it is very good practice to use this methodology. In this era of CYA, cover your A**, anything to help prevent problems is desirable.

I always thought that was "Conserve Your Assets". :smiley:

Couldn't the EDITOR value to pointed as somehting more "friendly" like ee for those that do not know the glory of vi yet?

I didn't even think about that...

If you're on a system that has something like pico installed, you could actually do this:

export VISUAL=/usr/bin/pico
crontab -e

I just tested this on a linux box, and it worked OK...