Linux / Unix – crontab: no crontab for user using an empty one error and solution

I am trying to set cronjob on a Unix systems by running the crontab -e command. But, I’m getting the following error:

ADVERTISEMENTS

crontab: no crontab for veryv – using an empty one
crontab: “/usr/bin/vi” exited with status 1

How do I fix this issue on a Linux or Unix-like systems?

[donotprint]
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Time1m
[/donotprint]You need to set correct environment variable called EDITOR. It appers that either vi is not installed or /usr/bin/vi is a symbolic link to vim editor. To edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables, enter:

$ crontab -e

But, if EDITOR or VISUAL is not set, so you will see an error as follows:

Fig.01: Linux crontab: no crontab for veryv  - using an empty one

Fig.01: Linux crontab: no crontab for veryv – using an empty one

So to fix this error and use vim as a text editor, type (bash/sh/ksh shell specific syntax):
export EDITOR=vim
OR if you are using emacs editor, run:
export EDITOR=emacs
Or if you are using nano text editor, enter:
export EDITOR=nano
Finally, try to edit or set new cron jobs, enter:
crontab -e
I recommend that you edit your shell ~/.bashrc file and append the following line:

export EDITOR=vim
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • Jignesh Boricha Sep 19, 2016 @ 11:47

    Hello There

    Thank you so much for this post. It helped me a lot.

    Actually I was trying setup CRON but I haven’t found the correct way and the missing
    point which I found here only.

    Again, Thank you for sharing this.

    Regards.
    Thank You.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.