该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’
然而以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的方式 将日志文件清空