如何在没有交互式编辑器的情况下使用Bash自动创建cron作业? [英] How to create a cron job using Bash automatically without the interactive editor?

查看:53
本文介绍了如何在没有交互式编辑器的情况下使用Bash自动创建cron作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

crontab是否具有用于在不使用编辑器的情况下创建cron作业的参数(crontab -e).如果是这样,那么从Bash脚本创建cronjob的代码是什么?

Does crontab have an argument for creating cron jobs without using the editor (crontab -e). If so, What would be the code create a cronjob from a Bash script?

推荐答案

您可以按如下所示将其添加到crontab中:

You can add to the crontab as follows:

#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "00 09 * * 1-5 echo hello" >> mycron
#install new cron file
crontab mycron
rm mycron


Cron行说明

* * * * * "command to be executed"
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

来源 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆