Arrays 在cron调用的脚本中声明数组的正确方法是什么?
我编写了一个KornShell(ksh)脚本,该脚本按以下方式设置数组: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
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运行吗?