I tried the below command and crontab stopped running any jobs: echo "@reboot /bin/echo 'test' > /home/user/test.sh"| crontab -
我尝试了下面的命令,crontab停止运行任何作业:echo“@reboot /bin/echo 'test' > /home/user/test.sh”| crontab -
What is the correct way to script adding a job to crontab in linux?
在linux中,将作业添加到crontab的正确方式是什么?
1 个解决方案
#1
3
I suggest you read Cron and Crontab usage and examples .
我建议您阅读Cron和Crontab的用法和示例。
And you can run this:
你可以这样运行:
➜ ( 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"
Or
或
#!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
Hope this helps.
希望这个有帮助。
#1
3
I suggest you read Cron and Crontab usage and examples .
我建议您阅读Cron和Crontab的用法和示例。
And you can run this:
你可以这样运行:
➜ ( 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"
Or
或
#!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
Hope this helps.
希望这个有帮助。