我尝试了以下命令,crontab 停止运行任何作业:
echo "@reboot/bin/echo 'test' >/home/user/test.sh"|定时任务-
在 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 -
希望这对您有所帮助。
关于linux - 如何使用 bash 脚本将 crontab 作业添加到 crontab?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42198960/