Linux: 查找并执行并发 xterm
Linux: Find and Execute Concurrent xterm
我正在尝试 运行 为文件夹集合中的每个实例创建一个客户端和服务器。我试过这个命令:
$ find ./ -name "Makefile" -execdir xterm -title "Server" -e "timeout -s sigint 8s ./server > serverLog.txt" \; -execdir xterm -title "Client" -e "timeout -s sigint 5s ./client > client1Log.txt" \;
但是这个 运行 xterm window 中的服务器 8 秒然后关闭 window 和 运行 xterm window 中的客户端持续 5 秒钟。对于找到的每个 Makefile,我需要客户端和服务器同时 运行。
要运行 同时执行两个命令,您必须使用琥珀符号&
,这会将第一个执行发送到后台并继续执行下一个。所以你必须执行类似
的东西
cmd1 & cmd2 &
或 cmd1 & cmd2
,这取决于你想要什么。
接下来你必须在 -execdir
内转义琥珀沙,它接受一个命令。一种方法是
find [params] -execdir sh -c 'cmd1 & cmd2' \;
示例:
find [params] -execdir sh -c 'xterm -e "sleep 8" & xterm -e "sleep 5"' \;
我正在尝试 运行 为文件夹集合中的每个实例创建一个客户端和服务器。我试过这个命令:
$ find ./ -name "Makefile" -execdir xterm -title "Server" -e "timeout -s sigint 8s ./server > serverLog.txt" \; -execdir xterm -title "Client" -e "timeout -s sigint 5s ./client > client1Log.txt" \;
但是这个 运行 xterm window 中的服务器 8 秒然后关闭 window 和 运行 xterm window 中的客户端持续 5 秒钟。对于找到的每个 Makefile,我需要客户端和服务器同时 运行。
要运行 同时执行两个命令,您必须使用琥珀符号&
,这会将第一个执行发送到后台并继续执行下一个。所以你必须执行类似
cmd1 & cmd2 &
或 cmd1 & cmd2
,这取决于你想要什么。
接下来你必须在 -execdir
内转义琥珀沙,它接受一个命令。一种方法是
find [params] -execdir sh -c 'cmd1 & cmd2' \;
示例:
find [params] -execdir sh -c 'xterm -e "sleep 8" & xterm -e "sleep 5"' \;