Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在cron调用的脚本中声明数组的正确方法是什么?_Arrays_Shell_Scripting_Cron_Ksh - Fatal编程技术网

Arrays 在cron调用的脚本中声明数组的正确方法是什么?

Arrays 在cron调用的脚本中声明数组的正确方法是什么?,arrays,shell,scripting,cron,ksh,Arrays,Shell,Scripting,Cron,Ksh,我编写了一个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

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

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

虽然我不确定这是最好的方法,但我还是设法用这种方法解决了这个问题:

尝试4:

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

myScript.sh
是否以

#!/bin/ksh

(或者您的ksh的路径是什么?

是否从
myScript.sh
开始

#!/bin/ksh

(或您的ksh的任何路径)?

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

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

如果它以#开头/bin/ksh,但仍然不能作为Kornshell脚本运行,这可能是因为脚本本身不可执行,因此cron作业试图将其作为Bourne(在Linux上,Bash)shell运行吗?如果它确实以#开头/bin/ksh,但仍然不能作为Kornshell脚本运行,这可能是因为脚本本身不可执行,因此cron作业试图将其作为Bourne(在Linux上,Bash)shell运行吗?