0

I'm using nohup to submit jobs in background in the machines I got through BSUB and ssh.

My primary machine is on RHEL, from there I am picking up other AIX machine by BSUB(Submits a job to LSF) and also doing a SSH login to another server. After getting these two machines, executing a script(inner.sh) there through nohup.

I'm capturing the respective PIDs through echo $$ in the script which I am executing(inner.sh). After submitting the nohup execution in background, I am exiting both of the machines and landing back to primary RHEL machine.

Now, from this RHEL machine, I'm trying to get the status of the nohup execution by ps -p PID with the help of the previously captured two PIDs, but not getting any process listed.

Top level wrapper script wrapper.sh:

#!/bin/bash

#login to a remote server
ssh -k xyz@abc < env_setup.sh

#picking up a AIX machine form LSF
bsub -q night -Is ksh -i env_setup.sh

ps -p process-<AIX_machine>.pid
#got no output
ps -p process-<server_machine>.pid
#got no output

Script passed to Machines picked up by BSUB/SSH to execute nohup env_setup.sh:

#!/bin/bash
nohup sh /path/to/dir/inner.sh > /path/to/dir/log-<hostname>.out &
exit

The actual script which I am trying to execute in machines picked up by BSUB/SSH inner.sh:

#!/bin/bash
echo $$ > /path/to/dir/process-<hostname>.pid
#hope this would give correct us the PID of the remote machine
#execute some other commands

Now, I am getting two process-<hostname>.pid files updated with two PIDs respectively each for both of the machines.

But ps -p at wrapper script is giving us no output.

I am picking up the process IDs from remote machines and doing ps -p at my local RHEL machine.

Is it the reason I am not getting any status update of those two processes?

Can I do anything else to get the status?

Foobar-naut
  • 111
  • 3
  • 11
  • 1
    `ps` is running on your local machine, so you are just looking at it's processes. You'll have to `ssh` or `bsub` into the remote machine and `ps` there. – JNevill Dec 20 '17 at 14:10
  • 1
    Are you expecting the commands after `ssh -k xyz@abc < env_setup.sh` to be running on `abc`? They're not. https://stackoverflow.com/questions/37586811/pass-commands-as-input-to-another-command-su-ssh-sh-etc – tripleee Dec 20 '17 at 14:29

1 Answers1

0

ps give the status of local processes. bsub can be used to get the status of processes on each remote machine.

Nahuel Fouilleul
  • 18,726
  • 2
  • 31
  • 36
  • Is it possible to get status of the remote machines which are specifically picked up from my local machine by _bsub_? – Foobar-naut Dec 20 '17 at 14:12
  • bsub + ps: if inner script echoes hostname + pid, then bsub or ssh machine + ps -p pid, note that pid can be re-used, maybe there is a misconception but the question didn't give the context – Nahuel Fouilleul Dec 20 '17 at 15:03