如何自动定时运行2个程序?
我在linux下工作。我有两个程序可以无限运行(也就是说,除非我终止该进程,否则不会停止)。我想先运行程序 1,然后在 20 秒后运行程序 2(当一个程序读取写入的文件时,这两个程序必须同时运行)由另一个)。目前,我正在通过手动跟踪时间来运行这两个程序。有没有办法自动执行此操作?即是否有任何命令或可以编写任何程序来执行此操作。
I'm working in linux. I have two programs that run for infinite time ( that is , wont stop unless i kill the process ).i want to run program 1 first and then run program 2 after 20 seconds ( both will have to run simultaneously as one reads a file written by the other ).Currently , i am running the 2 programs by manually keeping track of time.. Is there a way to automate this ? i.e. is there any command or can any program be written to do this..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 shell:
$program1 &睡眠 20 ;程序2
Using the shell:
$ program1 & sleep 20 ; program2
如果一个程序读取另一个程序的文件输出,则应考虑使用管道将一个程序的输出传递到另一个程序的输入:
$>;节目1 | program2
我假设您可以控制这两个程序,并且可以让它们写入
stdout
并从stdin
读取。If one program reads from the file output by the other you should consider using a pipe to pass output from one to the input of the other:
$> program1 | program2
I'm assuming that you have control over these two programs and can get them to write to
stdout
and read fromstdin
.