قالب وردپرس درنا توس
Home / Tips and Tricks / How to Change the Default Crontab Editor

How to Change the Default Crontab Editor



  Art representing bash shell on a Linux system
Fatmawati Achmad Zaenuri / Shutterstock.com

Would you like to use crontab the editor of your choice instead of the other way around? This tutorial will show you how. These instructions work with Linux, Mac OS, and other Unix-like operating systems.

The tricky subject of text editors

A text editor performs a rather banal task. But the deep feeling people associate with their personal preference editor has led to flaming wars that have been burning since 1

985. We do not stoke this fire and advocate no editor over another. We'll show you how to change the default editor for crontab into something else, if you choose.

The command crontab -e opens an editor so you can edit your cron table. Your cron table contains the list of all scheduled jobs that you ran at specific times. In this article we will not go into the details of cron jobs. We just look at the editor associated with the command crontab -e .

RELATED: How To Schedule Tasks Under Linux: An Introduction to Crontab Files

When you first issued the command crontab with the option -e (Edit) in a bash terminal, you will be prompted to select the desired editor. Type crontab a space, -e and press Enter.

  crontab -e 

  crontab -e

The editor you selected is then used to open your cron table. In this example, Nano was selected by pressing the 1 key.

 crontable in the Nano-Editor

The editor that you select from the menu is used in every edition of the crontab. e command. If you later change your mind, how do you choose another editor if you only get the menu the first time? That's easy. The command to use is Select Editor .

  Select Editor 

  Select Editor Command

So simple so far. But what if you want to use an editor that is not in this menu? Or what if you are working on an operating system that does not contain the select-editor command? We can also deal with these scenarios.

What about distros that Select Editor does not provide?

We can set the default editor for crontab by adding a line to our .bash_profile file. Type this command:

  gedit ~ / .bash_profile 

If the editor appears, add this entry to the file:

export VISUAL = "gedit"

 .bash_profile in gedit

Of course, you put in the command, which is the desired editor for & # 39; gedit & # 39; starts. Save this file and close the editor. For these changes to take effect, log off and on again, or enter the following command:

. ~ / .bash_profile 

<img class = "alignnone size-full wp-image-411058" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2019/04 /xnew_crontab_editor_05.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.vtDJdUdGat.png "alt =". ~ / .bash_profile (19459035) [19659006NotethatthelinestartswithaperiodorpointThecommand source is an alias for the period command and performs the same action, but not all distributions contain the command source [TheperiodcommandshouldalwaysbeinplaceAfterthisreservationwasmadethe source command was present on all distributions.This article was written against Ubuntu, Debian, Manjaro, Arch, Fedora Regardless of whether you enter a dot or the word source the command causes the settings to gel out of your .bash_profile and transferred to your current session. If you enter now:

  crontab -e 

The editor you specified will be used to open your cron table.

 Cron table in gedit

Your .bash_profile could not be empty

Your .bash_profile file may not be empty when you edit it. Just scroll down and add the line export VISUAL = "gedit" at the end of the file. This is the default .bash_profile in Manjaro Linux with the new line:

 Export line in .bash_profile

And finally OpenIndiana

With OpenIndiana you must add the ] export VISUAL = " gedit " line in your .bashrc file, not your .bash_profile. The command you need to enter is:

  pluma ~ / .bashrc 

 .bashrc in pluma

Add the line, save the file, close the terminal window, and reopen it

Enter the crontab -e command to see if your changes have taken effect:

  crontab -e 

 crontisch in nano openIndiana

And now your cron table is loaded in nano.

Now you can specify the editor of your choice for many Linux types, whether it comes from Debian, RedHat, Arch or something closer to a simple Vanilla Unix function.




Source link