在cron调用的脚本中声明一个数组的正确方法是什么? [英] What would be the right way to declare an array within a script that will be called by cron?
本文介绍了在cron调用的脚本中声明一个数组的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个KornShell(ksh)脚本,用以下方式设置数组:
香蕉草莓
但是当我试图从cron运行它时,会出现以下错误: / p>
您的myron上的cron作业
/myScript.sh
产生以下输出:
myScript.sh:-A:错误选项
我尝试过许多crontab语法变体,例如:
尝试1:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/myScript.sh
尝试2:
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:
10,15,20,25,30,35,40,45,50,55 * * * * cd / path / to / script&& ksh ./myScript.sh
I have written a KornShell (ksh) script that sets an array the following way:
set -A fruits Apple Orange Banana Strawberry
but when I am trying to run it from within cron, it raises the following error:
Your "cron" job on myhost /myScript.sh produced the following output: myScript.sh: -A: bad option(s)
I have tried many crontab syntax variants, such as:
Attempt 1:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/myScript.sh
Attempt 2:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/./myScript.sh
Attempt 3:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ./myScript.sh
Any workaround would be sincerely appreciated. Thanks much in advance!
解决方案Although I'm not sure it's the best way to do it, I've managed to solve it this way:
Attempt 4:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ksh ./myScript.sh
这篇关于在cron调用的脚本中声明一个数组的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文