title: How can I run nohup command in ansible playbook task?
body: <p>I am pretty much beginner with ansible. I am trying to migrate linux scripts to perform a remote server startup using the nohup command and it does not work properly. The ansible results state change: true, but when I check if the process is up, it doesn't. Thus, I have to restart it manually.</p>
  
  <p>Thanks for your help.</p>
  
  <hr>
  
  <p>Here what I am doing:</p>
  
  <pre><code>- name: "Performing remote startup on server {{ SERVER }}"
    command: nohup {{ JAVA_HOME }}/bin/java {{ DYNATRACE_AGENT_REUS }} -jar -Dengine={{ ENGINE_NAME }} name-{{ ENGINE_JAR_VERSION }}.jar --server.port={{ ENGINE_PORT }} &gt;{{ CONSOLE_LOG }} 2&gt;&amp;1 &amp;
    args:
      chdir: "{{ SOMEVAR_HOME }}"
      async: 75
      poll: 0
      register: out
    - debug: 
        msg: '{{ out }}'
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>TASK [Performing remote startup on server] ***********************************************************************************************************************************************************************************
  changed: [servername]
  
  TASK [debug] ********************************************************************************************************************************************************************************************************************************
  ok: [servername] =&gt; {
      "msg": {
          "ansible_job_id": "160551828781.28405",
          "changed": true,
          "failed": false,
          "finished": 0,
          "results_file": "/home/admindirectory/.ansible_async/160551828781.28405",
          "started": 1
      }
  }
  </code></pre>