Jenkins slave process on ubuntu not showing any logging

时光毁灭记忆、已成空白 提交于 2020-01-05 11:16:15

问题


I have an Ubuntu VM dedicated as a Jenkins slave. I wrote a one-liner script to run the slave jar, and I run that script from /etc/rc.local. When I run the script manually, I get a few lines of output showing that it's working. I've tried to define the rc.local line and the script so that it stores stdout/stderr in a file, but the file is always zero length, with a modtime of when I start the process.

In the following, some fields are elided with "=stuff=".

The end of my "/etc/rc.local" looks like this:

su -c "/home/=user=/bin/jenkinsconnect" =user=
exit 0

The "jenkinsconnect" script looks like this:

#! /bin/bash
java -jar /home/=user=/opnfv_slave_root/slave.jar -jnlpUrl https://=host=/ci/computer/att-build/slave-agent.jnlp -secret =secret= 2>&1 > /home/=user=/jc.log

As I said, "/home/=user=/jc.log" is always zero length, and the modtime is when I started the process.


回答1:


The 2>&1 > file syntax will not work. You should either:

  1. use &> for directing both stderr and stdout to a file, or
  2. surround the entire command with parentheses to capture the output:

    (java -jar /home/=user=/opnfv_slave_root/slave.jar ... 2>&1) > /home/=user=/jc.log



来源:https://stackoverflow.com/questions/29654808/jenkins-slave-process-on-ubuntu-not-showing-any-logging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!