Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

PID missing on my File.

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
mohtashims mohtashims is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 18 July 2017, 2:16 PM EDT
Posts: 724
Thanks: 190
Thanked 7 Times in 7 Posts
PID missing on my File.

I have 3 files namely run1.cmd, run2.cmd & run3.cmd


Code:
more run1.cmd

cd /tmp/scripts/app1/
nohup ./startserver.sh &

more run2.cmd

cd /tmp/scripts/app2/
nohup ./startserver.sh &

more run3.cmd

cd /tmp/scripts/app3/
nohup ./startserver.sh &

These scripts are kept on my [Linux] ansible server [SERVER-A]

I wish to execute these scripts executeall.sh from [SERVER-A] onto a remote Solaris server [SERVER-B] using ansible [ssh] tool like below.


Code:
more executeall.sh
./run1.cmd
./run2.cmd
./run3.cmd

After execution from SERVER-A i go to SERVER-B to check if the process is running.

On SERVER-B i see the three process running but strangely the process PID is not logging to nohup.out


Code:
fuser /tmp/scripts/app1/nohup.out
No Output

instead the PID is is showing for


Code:
fuser /tmp/scripts/app1/startserver.sh
: 23455o

Thus i also do not find any logging happening on nohup.out.

However, when i run the below


Code:
./run1.cmd
./run2.cmd
./run3.cmd

directly on SERVER-B i see the nohup.out logging and PID on nohup.out as desired.

Can you please explain why do i see this strange behavior and how can i address this problem ?

Last edited by mohtashims; 1 Week Ago at 10:53 AM..
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
MadeInGermany MadeInGermany is online now Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 27 July 2017, 2:26 PM EDT
Location: Simplicity
Posts: 3,642
Thanks: 285
Thanked 1,217 Times in 1,100 Posts
It's a feature of some shells to display the job nr and the PID of a started background process.
But the display goes to the terminal, not into the nohup.out.
The nohup.out only gets the output of the ./startserver.sh command.
The PID of the (last) background command can be written to a logfile, for example

Code:
echo $! >>logfile

Sponsored Links
    #3  
Old Unix and Linux 1 Week Ago
mohtashims mohtashims is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 18 July 2017, 2:16 PM EDT
Posts: 724
Thanks: 190
Thanked 7 Times in 7 Posts
Tools

Quote:
Originally Posted by MadeInGermany View Post
It's a feature of some shells to display the job nr and the PID of a started background process.
But the display goes to the terminal, not into the nohup.out.
The nohup.out only gets the output of the ./startserver.sh command.
The PID of the (last) background command can be written to a logfile, for example

Code:
echo $! >>logfile

This is a show stopper and only if I could get a feasible solution.

1. if the PID goes to startserver.sh instead of nohup.out ... that's is fine but why no logging in the nohup.out ?? We need logging to the nohup.out irrespective of whether it is the startserver.sh or the nohup.out that gets the PID.

2. We need to get the pid of the process inorder to kill it automatically thus we cannot enforce everyone starting our servers to echo $! >>logfile

They may start as they like. Hence fuser of the file name was a feasible option to get the pid and kill it using automation.
    #4  
Old Unix and Linux 1 Week Ago
MadeInGermany MadeInGermany is online now Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 27 July 2017, 2:26 PM EDT
Location: Simplicity
Posts: 3,642
Thanks: 285
Thanked 1,217 Times in 1,100 Posts
Does the remote user have a csh/tcsh login shell?
Then nohup is a builtin - it does not use nohup.out file.
Use /usr/bin/nohup or \nohup to skip a builtin or alias.
The Following User Says Thank You to MadeInGermany For This Useful Post:
rbatte1 (1 Week Ago)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Systemd errors of missing file “No such file or directory” inspite of file being present rupeshkp728 Shell Programming and Scripting 0 12-14-2016 03:13 AM
File Extension Missing in file-$var.csv Cludgie UNIX for Dummies Questions & Answers 3 09-16-2015 12:02 PM
Yum - resolving missing dependencies that are not missing gw1500se Red Hat 13 11-21-2013 02:43 PM
How to resolve missing missing dependencies with opensuse 11.3 and 12.3? LMHmedchem SuSE 2 10-23-2013 04:30 PM
need to print the missing lines in 1 file from 1 file via script dazdseg Shell Programming and Scripting 8 06-04-2010 03:09 PM



All times are GMT -4. The time now is 02:51 PM.