
我寫了一個名為t.sh 其內容為:
touch 88888
我正在使用的命令是
sh t.sh | at 03:13Jun15
執行此命令後,我的螢幕上顯示了以下內容:
warning: commands will be executed using /bin/sh
job 9 at Sun Jun 15 03:13:00 2014
它非常清楚地表明這將在 Sun Jun 15 03:13:00 2014 執行
但是當我檢查我的資料夾時,我發現那裡存在一個 88888 個檔案。我把它移開並再次嘗試,仍然是相同的結果。
這裡有什麼問題呢?這會是 bash/sh 的事嗎?因為我看到它說將由/bin/sh執行?
答案1
at
從標準輸入讀取命令,如果指定標誌,則從檔案讀取命令-f
。所做sh t.sh | at [time]
的是:
1. execute the shell script t.sh *right now*;
2. pipe the output of the shell script to at.
但該腳本沒有輸出,因此週日沒有任何內容可執行。
你想要的是at 03:13Jun15 -f t.sh
。