How to run multiple jar files at once using shell

2019-08-01 07:46发布

Similar question related to Batch script has an answer. But I need same in shell script.

1条回答
对你真心纯属浪费
2楼-- · 2019-08-01 08:14

Just launch your jar adding a & at the end Example :

#!/bin/bash

java -jar myjar1.jar &
java -jar myjar2.jar &
java -jar myjar3.jar &

If you want the jar keep running after closing the terminal, use nohup :

#!/bin/bash

nohup java -jar myjar1.jar &
nohup java -jar myjar2.jar &
nohup java -jar myjar3.jar &

I use it in a project, works like a charm.

查看更多
登录 后发表回答