首页 > 解决方案 > 测试命令不在 Crontab 中运行

问题描述

在 Ksh shell 中,我的以下命令运行正常。

test "$(($(date +%W)%4))" -eq 2 && echo "yes" > /u/crmprod/test

但它不能使用下面的 crontab 运行。请问这个怎么解决?

34 00 * * 2 test "$(($(date +%W)%4))" -eq 2 && echo "yes2" > /u/crmprod/test

标签: unixksh

解决方案


所以,最后我只是将相同的命令放入一个文件中

$> cat /u/crmprod/mytest.scr
test "$(($(date +%W)%4))" -eq 2 && echo "yes2" > /u/crmprod/test

并在下面的 crontab 中成功运行。

* * * * * ksh /u/crmprod/mytest.scr

推荐阅读