2008-11-20 22 views
0

我已經寫了KornShell(KSH)腳本,設置一個數組方式如下:在cron中調用的腳本中聲明一個數組的正確方法是什麼?

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 

任何變通方法將誠心理解。非常感謝!

回答

1

雖然我不知道它是做的最好的方式,我已經成功地解決這樣說:

嘗試4:

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

是否myScript.sh開始與

#!/bin/ksh 

(或任何你的ksh的路徑)?

+0

確實如此。感謝您的反饋! – 2008-11-21 05:05:18

3

*/5 * * * * cd /path/to/script && ksh ./myScript.sh: - 它將每5分鐘運行一次。 也在cron本身中定義路徑變量。

相關問題