unix - 测试命令不在 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
解决方案
所以,最后我只是将相同的命令放入一个文件中
$> cat /u/crmprod/mytest.scr
test "$(($(date +%W)%4))" -eq 2 && echo "yes2" > /u/crmprod/test
并在下面的 crontab 中成功运行。
* * * * * ksh /u/crmprod/mytest.scr
推荐阅读
- bash - 历史命令未被识别为 child_process 中的内部命令
- python - 从源代码安装python3.6时没有名为venv的模块
- reactjs - 如何在每次重新渲染时改变反应钩子中的状态变量?
- sql - 在sql server中合并行
- android-studio - 在 Android Studio 中隐藏图标并将布局缩放默认设置为 25%
- r - 如何让我的李克特图表从发散变为收敛?
- postgresql - 从 postgresql 上损坏的外键剩余部分中恢复
- reactjs - Apollo GraphQL 反应突变未正确更新 UI
- java - 用Java将字节数组上传到FTP
- python - 表格化 lmfit 拟合参数