crontab 创建错误

crontab 创建错误

crontab使用创建时crontab -e,我无法编辑。它显示:

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command

答案1

显示正确,这就是要编辑的文件。也许您的默认编辑器是 vi 或 vim,那么您需要知道如何使用这些编辑器进行编辑。

要了解如何使用 vi 或 vim 进行编辑:vimtutor

要更改默认编辑器,请参阅: 更改默认 crontab 编辑器

答案2

设置系统范围的默认编辑器:

$ sudo update-alternatives --config editor

您还可以将环境变量设置$EDITOR为 ~/.profile 文件:

export EDITOR=nano

相关内容