在bash脚本按顺序运行命令 [英] Sequentially run commands in bash script

查看:144
本文介绍了在bash脚本按顺序运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行顺序在守护进程模式两个命令(命令将输出stderr上错误)。问题是,即使我在倾倒的/ dev / null的所有的输出,第二个命令(run_cmd2)不能被调用。这里是我的脚本

I need to run two commands sequentially in daemon mode (the commands will output the errors on stderr). The problem is that even I dump all the output in /dev/null, the second command (run_cmd2) cannot be invoked. Here is my script

#! /bin/bash
nohup ./run_cmd1 &> /dev/null &
nohup ./run_cmd2 &> /dev/null &

任何想法?先谢谢你。

Any ideas? Thank you in advance.

推荐答案

如何使用文件进行通信的状态?

How about using a file to communicate state?

run_cmd2会等到一个文件存在运行前

run_cmd2 will wait until a file exists before running

当run_cmd1完成后,它会创建表示文件。

when run_cmd1 is done, it will create the said file.

在其运行run_cmd2将删除该文件的结尾,所以run_cmd1可以再次运行

at the end of its run the run_cmd2 will delete the file, so run_cmd1 can run again

或者他们使用端口相互交谈?

Or maybe they talk to each other using a port?

也许一个信号?

有关详细信息: http://www.tldp.org/LDP/ TLK / IPC / ipc.html

这篇关于在bash脚本按顺序运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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