linux 后台运行java命令

前台运行:

java -classpath xwhb-api-1.0-SNAPSHOT-jar-with-dependencies.jar RunInOneServerVersion

后台运行:(默认输出信息到 nohup.out 具体哪不清楚...)

nohup java -classpath xwhb-api-1.0-SNAPSHOT-jar-with-dependencies.jar RunInOneServerVersion

 

碰到 nohup: ignoring input and appending output to `nohup.out' 表示 nohup.out 没权限操作 可像下面运行

使用的是Linux重定向的方法,将nohup.out重定向至一个有写入权限的路径,或者直接扔到/dev/null无底洞中。

nohup java -classpath xwhb-api-1.0-SNAPSHOT-jar-with-dependencies.jar RunInOneServerVersion 10 ./program >/dev/null 2>/dev/null &

10 是 RunInOneServerVersion类接收的参数 :

 

    public static void main(String[] args) {
        System.out.println("默认 2 分钟后 服务开启接收请求 ");
        if (args.length != 0) {

            CURRENT = args[0];

 

posted on 2018-03-29 18:10  --LP--  阅读(435)  评论(0编辑  收藏  举报

导航