What would be the correct way to declare an array inside a script that will be called by cron?

I wrote a KornShell (ksh) script that sets up an array like this:

set -A fruits Apple Orange Banana Strawberry


but when i try to run it from inside cron it throws the following error:

Your "cron" job on myhost

produced the following output:

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


I've tried many variations of the crontab syntax, for example:

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. Many thanks!


source to share

3 answers

Although I'm not sure if this is the best way to do it, I managed to solve this problem as follows:

Attempt 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

: - it will run every 5 minutes. Define Path variables also in cron itself.



Does it include myScript.sh




(or what would be the path for your ksh)?



All Articles