繁体   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