用-e替换crontab文件 [英] replace crontab file with -e
问题描述
任何人都知道将文件放入crontab -e的方法吗?我无法使用常规形式的crontab为其提供路径,但仍然需要替换整个内容。
Anyone know a way to give a file into crontab -e ? I cannot use the regular form of crontab giving it a path but still need to replace the whole contents.
也许将EDITOR设置为某些内容?
Perhaps setting EDITOR to something?
推荐答案
您可以使用
crontab /path/to/cron/file/name
使其更易于理解缘故,请使用箭头<
进行采购。
To make it more explicit for readability's sake, use the arrow <
for sourcing.
crontab < /path/to/cron/file/name
以这种方式采购cron作业会引发错误<$如果计划中的crontab条目在语法上无效,则crontab文件中的c $ c>错误,无法安装,因此请确保cron条目正确。
Sourcing the cron jobs this way can throw error errors in crontab file, can't install
in case the crontab entry you have are syntactically invalid in terms of scheduling, so make sure the cron entries are correct.
还请注意,这将完全丢弃现有的cronjob,并加载您传递的文件中存在的cronjob,因此使用可能有助于将现有cron条目保存在文件中crontab -l> cron.backup
Also note that this will completely discard existing cronjobs and load the ones which are there in the file you pass, so it might help to save existing cron entries in a file using crontab -l > cron.backup
编辑
您正在寻找一种方法来更改默认编辑器(以gedit或vi或其他方式),而不是从文件中获取cronjobs的方法,则可以导出 VISUAL
并 EDITOR
路径变量
In case you are looking for a way to change your default editor (to gedit or vi or something else) and not for a way to source cronjobs from file, you can export the VISUAL
and EDITOR
Path variables
export VISUAL=vim
export EDITOR=vim
这篇关于用-e替换crontab文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!