如何在特定时间在Linux上运行脚本? [英] How to run a script at a certain time on Linux?

查看:152
本文介绍了如何在特定时间在Linux上运行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含特定日期和时间的文本文件. 我希望能够在该文件中指定的时间运行脚本. 您将如何实现? 创建另一个在后台运行的脚本(有点像守护进程),并每秒检查当前时间是否与文件中的时间匹配? 还有另一种方法吗? 这台机器是Debian wheezy的 linux 服务器. 预先感谢

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.html http://manpages.ubuntu.com/manpages/xenial/man1/at .1posix.html

希望有帮助!

这篇关于如何在特定时间在Linux上运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆