簡體   English   中英

在shell腳本中使用at命令來調度命令

[英]Using at command in shell script for scheduling a command

我試圖使用“at”命令的功能來安排在某個用戶定義的時間執行任何特定命令。 想知道它是否可以使用“at”命令。 我希望“at”可以幫助我,因為我沒有權限安排cron任務。

我嘗試過的事情:

user>touch testfile |at 03:00  
job 30 at 2014-12-31 03:00  
user>ls -lrt testfile  
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile  <-----file created with command execution  
user>  

user> touch testfile1 | at -f 03:01
Garbled time
user>ls -lrt testfile*
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile1

采用:

echo "touch testfile" | at 03:00

你正在運行touch testfile ,並將其輸出touch testfileat 輸入要at應該是要運行的命令,而不是命令的輸出。

如果要運行多個命令,請使用here-doc:

at 03:00 <<EOF
touch testfile
touch testfile1
EOF

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM