如何在 Linux 上的某个时间运行脚本? [英] How to run a script at a certain time on Linux?
问题描述
我有一个包含特定日期和时间的文本文件.我希望能够在该文件中指定的时间运行脚本.你会如何做到这一点?创建另一个在后台运行的脚本(类似于守护进程)并每秒检查当前时间是否与文件中的时间匹配?还有其他方法吗?机器是linux服务器,Debian wheezy.提前致谢
I have a text file containing a specific date and time. I want to be able to run a script at the time specified in that file. How would you achieve that? Create another script that runs in background (sort of a deamon) and checks every second if the current time is matching the time in the file? Is there another way? The machine is a linux server , Debian wheezy. Thanks in advance
推荐答案
请看以下内容:
echo "ls -l" | at 07:00
此代码行在特定时间执行ls -l".这是在特定时间执行某事(在我的示例中为命令)的示例.at"是您真正要查找的命令.您可以在此处阅读规格:
This code line executes "ls -l" at a specific time. This is an example of executing something (a command in my example) at a specific time. "at" is the command you were really looking for. You can read the specifications here:
http://manpages.ubuntu.com/manpages/精确/en/man1/at.1posix.htmlhttp://manpages.ubuntu.com/manpages/xenial/man1/at.1posix.html
希望能帮到你!
这篇关于如何在 Linux 上的某个时间运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!