How to run .jar continually and automatically on Debian server?

后端 未结 3 1235
谎友^
谎友^ 2021-01-25 22:48

I have a .jar file I want to run all the time on a Debian server.

Currently I have figured out how to access the server via ssh on

3条回答
  •  误落风尘
    2021-01-25 23:27

    Simplest solution is to detach process by using nohup with &:

    nohup java -jar myjar.jar packageName.fileNameOfFileWithMainMethod &
    

    to stop process will be possible with kill command

    process id could be found by ps -ef | grep packageName.fileNameOfFileWithMainMethod

    But if you are developing serious application that is long-running on server you have to deal with initialization system like systemd, upstart or something like that.

提交回复
热议问题