我编写了一个KornShell(ksh)脚本,它按以下方式设置数组:

set -A fruits Apple Orange Banana Strawberry

但是当我尝试从cron中运行它时,它会引发以下错误:

Your "cron" job on myhost
/myScript.sh

produced the following output:

myScript.sh: -A: bad option(s)

我尝试了很多crontab语法变体,例如:

尝试1:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/myScript.sh

尝试2:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/./myScript.sh

尝试3:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ./myScript.sh

任何解决方法都将得到真诚的感谢。非常感谢!

有帮助吗?

解决方案 3

虽然我不确定这是最好的方法,但我已经成功解决了这个问题:

尝试4:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ksh ./myScript.sh

其他提示

*/5 * * * * cd /path/to/script && ksh ./myScript.sh: - 它将每5分钟运行一次。 在cron中也定义Path变量。

myScript.sh

开头
#!/bin/ksh

(或者你的ksh的路径是什么?)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top