我们将下面的一行添加到crontab (脚本- test.bash应该每分钟运行一次)
* * * * * root [[ -f test.bash ]] && /tmp/test.bash剧本是这样的
more test.bash
#!/bin/bash
echo TEST >/tmp/file.txt但是即使在几分钟后我们也看不到/tmp/file.txt上的任何内容
下面的crontab语法有什么问题?
* * * * * root [[ -f test.bash ]] && /tmp/test.bash我们也试着
* * * * * root [[ -f test.bash ]] && bash /tmp/test.bash但仍然/tmp/file.txt文件为空
发布于 2020-09-29 13:11:56
crontab command参数不是bash。command只是简单地传递给execve系统调用,而不需要解释。在您的bash脚本中执行bash语言(如[[),而不是在crontab command参数中执行。
https://unix.stackexchange.com/questions/611995
复制相似问题