欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java调用shell脚本

程序员文章站 2024-02-19 13:58:06
...
 String bashCommand = "/home/go/script/restart_go.sh";  //①
    Runtime runtime = Runtime.getRuntime();
    Process pro = runtime.exec(bashCommand);  //②
    int status = pro.waitFor();  //③
    if (status != 0){  //④
        logger.error("restart go server error");
        return;
    }
    logger.info("restart go server success");

 

转载地址:https://www.jianshu.com/p/462647582abe 

相关标签: java java