java 生成linux shell 脚本,java调用shell脚本,不生成日志文件?

该shell文件,在linux中,命令启动正常,能正常输出对应文件夹中的日志

[root@iZwz93b4gvgxj04g2nw0axZ zypx-company-service]# source /home/prog/xianning/部署/reload.sh

nohup: ignoring input and appending output to ‘nohup.out’

nohup: ignoring input and appending output to ‘nohup.out’

nohup: ignoring input and appending output to ‘nohup.out’

nohup: ignoring input and appending output to ‘nohup.out’

[root@iZwz93b4gvgxj04g2nw0axZ zypx-study-service]# nohup: ignoring input and appending output to ‘nohup.out’

nohup: ignoring input and appending output to ‘nohup.out’

07b9470ef0b63bb55ef7ac1a7240a23b.png

然而以JAVA程序调用时,nohup.out日志文件被删除后,没有生成,但是jar包是后台运行的,项目可以访问。

@RequestMapping(value = "/upReload")

public void upReload() throws IOException {

// 重启服务

String commend = "bash /home/prog/xianning/部署/reload.sh";

// 调用cmd

Process exec = Runtime.getRuntime().exec(commend);

}

怎么能在java调用时正常输出日志文件?(shell . ./启动过没有解决)

为什么要删除nohup日志文件?删除文件 如果进程不重启的情况下,句柄是没有释放的,所以程序运行不受影响,同时磁盘也不会释放。

解决方案:

1、重启进程 就会释放文件句柄 并生成新的日志文件了

2、可以使用>nohup.out的方式 将日志文件清空

73bccf0c0b4af35beddca4274520fb45.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值