linux-如何使用bash脚本将crontab作业添加到crontab?
作者:互联网
我尝试了以下命令,crontab停止运行任何作业:
echo“ @reboot / bin / echo’test’> /home/user/test.sh” | crontab-
在Linux中将作业添加到crontab的脚本的正确方法是什么?
解决方法:
我建议您阅读Cron and Crontab usage and examples .
您可以运行以下命令:
➜ ( printf -- '0 4 8-14 * * test $(date +\%u) -eq 7 && echo "2nd Sunday"' ) | crontab
➜ crontab -l
0 4 8-14 * * test $(date +\0) -eq 7 && echo "2nd Sunday"
要么
#!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
希望这可以帮助.
标签:cron,crontab,ubuntu-16-04,ubuntu-server,linux 来源: https://codeday.me/bug/20191026/1935065.html