在通过ssh启动的脚本中,詹金斯似乎是nohup的目标,我该如何防止呢? [英] Jenkins seems to be the target for nohup in a script started via ssh, how can I prevent that?

查看:454
本文介绍了在通过ssh启动的脚本中,詹金斯似乎是nohup的目标,我该如何防止呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Jenkins作业,以重新启动始终在我们的一台服务器上运行的程序.

I am trying to create a Jenkins job that restarts a program that runs all the time on one of our servers.

我将以下内容指定为要运行的命令:

I specify the following as the command to run:

cd /usr/local/tool && ./tool stop && ./tool start

脚本工具"包含如下一行:

The script 'tool' contains a line like:

nohup java NameOfClass &

该命令的输出最终在我的构建控制台中,而不是在nohup.out中,因此该作业永远不会终止,除非我手动终止它,这会终止程序.

The output of that ends up in my build console instead of in nohup.out, so the job never terminates unless I terminate it manually, which terminates the program.

如何使nohup的行为与从终端执行的行为相同?

How can I cause nohup to behave the same way it does from a terminal?

推荐答案

如果我正确理解了这个问题,Jenkins将在构建结束时终止所有进程,并且您希望在构建完成后保留某些进程运行

If I understood the question correctly, Jenkins is killing all processes at the end of the build and you would like some process to be left running after the build has finished.

您应该阅读> https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller

本质上,Jenkins会在BUILD_ID环境变量中搜索具有某些秘密值的进程.只需覆盖它即可保留您想单独处理的流程.

Essentially, Jenkins searches for processes with some secret value in BUILD_ID environment variable. Just override it for the processes you want to be left alone.

这篇关于在通过ssh启动的脚本中,詹金斯似乎是nohup的目标,我该如何防止呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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