0

我编写了一个 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

任何解决方法将不胜感激。提前非常感谢!

4

3 回答 3

3

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

于 2011-11-29T09:33:01.710 回答
2

是否myScript.sh开始

#!/bin/ksh

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

于 2008-11-20T21:18:08.680 回答
1

虽然我不确定这是最好的方法,但我已经设法通过这种方式解决它:

尝试4:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ksh ./myScript.sh
于 2008-11-20T20:08:04.420 回答