本文共 716 字,大约阅读时间需要 2 分钟。
crontab -e
will an editor to edit the crontab entries. But how to add a crontab entry from a shell script on without interaction from users?
crontab -e
将编辑器来编辑crontab条目。 但是如何在上的shell脚本中添加crontab条目而又无需用户交互?
You can try this piece of script:
您可以尝试以下脚本:
(crontab -l; echo "@reboot echo "rebooted"";) | crontab -
Note that the update by this line of script is not atomic. If some other programs edit the crontab between the first and second invokes of crontab
, the edits will be lost. Hence, make sure there is not other programs/admins editing the crontab when you use this piece of script.
请注意,此脚本行的更新不是原子的。 如果其他一些程序编辑crontab 的第一和第二所调用之间crontab
中,编辑将丢失。 因此,使用此脚本时,请确保没有其他程序/管理员在编辑crontab。
翻译自:
转载地址:http://dilwd.baihongyu.com/