자바 조작 리 눅 스

659 단어 LogJavaLinux
Java조작Linux실행 스 크 립 트 사용java.lang.Runtime
import lombok.extern.slf4j.Slf4j;

/**
  * @Title callCloseCommand
  * @Description         
  * @Param
  * @param
  * @return void
  **/
private void callCloseCommand() {
  String command = "./server.sh stop";
  log.error("      API  ,   IP  ", command);
  try {
    Runtime.getRuntime().exec(command);

  } catch (Exception e) {
    log.error("Linux       ,{}", command);
    e.printStackTrace();
  }
}
  • 주:실제 상황 에 따라command내용 을 조정 하여linux문 구 를 변경 할 수도 있다.예 를 들 어./server.sh restart
  • 좋은 웹페이지 즐겨찾기