How to edit CRONTAB file on Solaris

Wednesday, July 22, 2009

I rarely edit crontab files on our Solaris machines but then when I need to add or edit something I always experience the same problem and always searching for an answer 5-10 minutes. This time I will write solution in blog post for quick reminder.

Problem is, when I execute "crontab -e" to edit current crontab file I don't get editor window.
I get something like this:

bash-2.05$ crontab -e

My problem is that I don't have EDITOR environment variable set.

I have to do something like this:

bash-2.05$ export EDITOR=vi
bash-2.05$ crontab -e

#Then I will receive proper output to edit crontab file
30 21 * * * /opt/oracle/product/9.2.0/local/script1
30 22 * * * /opt/oracle/product/9.2.0/local/script2

To avoid this problem happening any more I will add EDITOR environment variable in my ".profile" file:

bash-2.05$ cd ~
bash-2.05$ vi .profile

set -am -o vi
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/9.2.0
export EDITOR=vi
export ORACLE_SID=db
exec bash

Now, every time I login on this machine environment variable for EDITOR will be automatically set and I won't have problems with "crontab -e" any more.



  • 8gb micro sd karte

    Cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris. Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

  • Mike

    Good post, thanks for the tip.

  • Thanks for the post - noticed that:

    export EDITOR=vi

    gave an error

    EDITOR=vi: is not an identifier


    export EDITOR

    albeit didn't get as far as adding it to .profile

  • Marko Sutic

    Yes, if you're using Solaris sh then this two steps are needed.

    You can also add this two steps in .profile.

    Thanks for comment!


  • Thank you! Very helpful.

  • Post a Comment