Linux如何在特定时间运行脚本? [英] Linux How to run script at certain time?
问题描述
我有一个包含特定日期和时间的文本文件。
我希望能够在该文件中指定的时间运行脚本。
你会如何实现?
创建另一个在后台运行的脚本(排除deamon),如果当前时间与文件中的时间匹配,则每隔一秒检查一次
有另一种方式吗?
这台机器是一个 linux 服务器,Debian喘不过气来。
提前感谢
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/precise/en/man1/at.1posix.html
http://manpages.ubuntu.com/manpages/xenial/man1/at.1posix.html
希望有帮助!
这篇关于Linux如何在特定时间运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!