bash 脚本将在 5 分钟内运行
我只想让 bash 脚本在调用后运行 5 分钟。我做错了什么?
我有命令:
/path/to/my/script | at now + 5 min
但脚本每次都会立即运行。
I just want a bash script to run 5 minutes after it's called. What am I doing wrong?
I have the command:
/path/to/my/script | at now + 5 min
And yet the script runs right away every time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您将立即执行脚本并将其输出发送到
at
。您需要将脚本本身的名称发送到at
:You are executing the script immediately and sending its output into
at
. You need to send the name of the script itself intoat
:怎么样:
how about:
这应该可以安排脚本在特定时间运行。有关“
at
”命令的更多信息,请尝试 linuxmanpages.com。我的想法可能是错误的(目前没有在linux系统上进行测试)。无论如何祝你好运
This should work as far as scheduling a script to run at a specific time. For any more information on the "
at
" command try linuxmanpages.com. I may be wrong thought ( currently not at a linux system to test ).Good luck anyways
问题是您正在运行脚本并将输出通过管道传输到
at
命令。您需要做的是运行at
命令,并将脚本的路径作为参数。我不确定语法,但at -h
或man at
应该有帮助。The problem is you're running the script and piping the output to the
at
command. What you need to do is run theat
command with the path to your script as a parameter. I'm not sure of the syntax, butat -h
orman at
should help.命令是从左到右评估的,因此首先执行您的脚本,其输出将通过管道传输到 at 命令,这是正常行为。有关详细信息,请参阅 at 手册页。
Commands are evaluated left to right, so first your script gets executed, the output of it will be piped to the at command, this is normal behaviour. Have look at at the at man pages for more information.
试试这个
sys.scheduled_run /path/to/my/script 5
main function
倒计时功能
try this
sys.scheduled_run /path/to/my/script 5
main function
countdown function