我有一个奇怪的问题,即能够从命令行运行bash脚本,但不能从root的crontab条目运行.我正在运行Ubuntu 12.04.
* * * * 1-5 root /home/xxxxxx/jmeter/VerificationService-0.0.1-SNAPSHOT/jmeter-cron-randomise.sh >> /home/xxxxxxx/jmeter/VerificationService-0.0.1-SNAPSHOT/cron.log
Run Code Online (Sandbox Code Playgroud)
如果我使用bash从cmd行运行脚本,它可以正常工作但sh失败并出现以下错误:
> jmeter-cron-randomise.sh: 7: jmeter-cron-randomise.sh: arithmetic
> expression: expecting primary: " % 1 "
Run Code Online (Sandbox Code Playgroud)
谷歌搜索了问题,似乎标准shell没有像bash一样的数学运算符,如%(模数).我不确定为什么cron作业在脚本中失败了?我假设它是因为它没有使用bash shell?它肯定是由cron守护进程触发的(可以在/ var/log/syslog中看到它).任何帮助非常感谢.