如何同時 nohup 多個 SAS 程式?

如何同時 nohup 多個 SAS 程式?

我有幾個 SAS 程式

test1_2.sas
test3_4.sas
test7_8.sas

我希望nohup立即獲得這些腳本。我嘗試創建一個外殼包裝器,例如test.sh

#test running multiple files
testing1_2.sas &
testing3_4.sas &

我嘗試打電話給nohup sas test.sh &nohup test.sh &。當它明確保存在資料夾中時,這兩個命令都告訴我test.sh不在當前目錄中。

我對 shell 腳本編寫還很陌生,並且希望獲得一些幫助來找到nohup在多個 SAS 程式上運行的正確方法。謝謝!

答案1

我不是 nohup 的忠實粉絲(我使用 disown 代替),但是如果您將 'nohup' 放在 shell 腳本中的每個命令前面,它將完成您問題的 nohup 部分。

不過,我認為你的檔案是SAS程式?如果您希望 SAS 在每個 SAS 程式上並行運行:

nohup sas test1_2.sas &
nohup sas test3_4.sas &
etc.

它將執行獨立的 SAS 命令,每個命令都有自己的 SAS 程式。

繼續使用 nohup 指令,如果它們產生輸出,它們將同時寫入 nohup.out。為了防止這種情況,請將每個命令的輸出和錯誤訊息寫入單獨的檔案中:

nohup sas test1_2.sas > output1_2.file 2>&1 &
nohup sas test3_4.sas > output3_4.file 2>&1 &
etc.

添加以包含評論中的程式碼:

呼叫 test.sh 命令

bash test.sh

(其中“bash”是您最喜歡的 shell)或將其標記為可執行檔:

chmod +x test.sh

由於您是新用戶,如果您認為這是問題的正確答案,請確保並點擊複選標記。

相關內容