无法从jenkins运行nohup命令作为后台进程 [英] Unable to run nohup command from jenkins as a background process

查看:1126
本文介绍了无法从jenkins运行nohup命令作为后台进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:基于以下讨论,我对答案进行了编辑,以进行更准确的描述.

UPDATE: Based on below discussion I have edited my answer for more accurate description.

我正在尝试从jenkins运行nohup命令.完整的命令是

I am trying to run a nohup command from jenkins. The full command is

nohup java -jar /home/.../jar/server-process-0.35.jar prod >> /var/../server-process-prod.log 2>&1 &

此命令不起作用.我可以在jenkins中将状态视为成功,但在Linux中则看不到Java进程.当我做ps -ef | grep java'

This command does not work. I can see status as success in jenkins but no java process in linux. When I do 'ps -ef | grep java'

但是,当我删除最后一个'&'时,即我将其更改为从Forground而不是背景运行

However when I remove the last '&' , that is I change it from run in forground instead of background

它开始工作.我可以看到Java进程已启动.

It starts working. I can see the java process started.

如果我在linux控制台上运行原始命令,该命令就可以正常工作.

The original command works fine If I run it on linux console.

我需要从jenkins以原始形式运行它,这是backgorund进程.这样它就独立于詹金斯.

I need to run it from jenkins in the original form that is as a backgorund process. So that it is independant of jenkins.

任何线索为什么会这样?

Any clues why is this happening?

推荐答案

在您的jenkins shell脚本中尝试:

In your jenkins shell script try:

  export BUILD_ID=dontKillMe
  nohup java -jar your_java_app.jar &

对我有用!

这篇关于无法从jenkins运行nohup命令作为后台进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆