I have a bash script which need to start some process on remote machine.
I have done that using sshpass
command.
I need to store the PID of that remote process.
I tried the following with a script:
sshpass -p password ssh user@ipaddr /bin/bash << EOF
nohup process > /dev/null 2>&1 & echo $! > pid_file
cat pid_file
EOF
when I check with remote machine, the process is started and pid_file also has a number written in it. But the process id and number of pid_file do not match.
Executing the above set of commands directly on terminal without script, doesn't write anything in pid_file.
Can somebody help in storing the right pid of remote process.