Sponsored Content
Top Forums Shell Programming and Scripting [SOLVED] Using "$!" to get the PID of the Last Ran Background Process Post 302703751 by mrm5102 on Thursday 20th of September 2012 11:38:20 AM
Old 09-20-2012
Hey Methyl, thanks again for the reply.

In my original question I posted both Operating Systems that I have been testing on (i.e. SLES 11.1 (Bash v3.2.51) -and- AIX 6 (KSH))...
I guess I should have made it a little more noticeable, sorry about that...

Also, on the AIX one I have installed Bash version 3.2.16(1), which is what I've been using to write my scripts.

Thanks for your suggestion I'll give it a try and post back...
Also, before that, I wanted to mention that I'm ssh'ed into the SLES server and opened up my script using:
Code:
# gedit myScript &
# echo $!
30398
# ps -ef | grep [g]edit
root     30398 30317  0 09:42 pts/0    00:00:00 gedit checkNRPE

As you can see it actually worked this time!
This leads me to believe that possibly another "background process" (or something like that) is begin started when
I issue the command to start the Daemon...?

Does this sound like a possibility..?


Thanks Again,
Matt

---------- Post updated at 11:38 AM ---------- Previous update was at 09:59 AM ----------

Hello Again,

I just tried your command (with the 'nohup') and still getting the same results.

Here is the exact output when issuing those commands:
Code:
# nohup /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d &
[1] 2927
nohup: ignoring input and appending output to `nohup.out`
# echo $!
2927
[1]+  Done                    nohup /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
# ps -ef | grep 2927
root      2937  2431  0 11:31 pts/4    00:00:00 grep 2927

So I'm guessing there is something weird going on within that command when I execute it...

I'm thinking of just starting the Daemon from within a Bash script, then within that script
just find the PID after it's started and write it to a file...


Thanks Again for Your Help,
Matt
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Process seen in "ps aux" but not "top"

Hi, I have a process that can be seen after "ps aux" command. However when I do "top" command. This process cannot be seen. How can this happen? Is there anything wrong with my code? (3 Replies)
Discussion started by: monkfan
3 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

How to include RETURN KEY with Background process "&" in Shell Script

Hello All, I am a newbie in Shell script programming, and maybe you can help me with my query. I need to write a shell script (mntServer.ksh) that will start a background process and also to be able to run another script. The mntServer.ksh script contains: #!/bin/ksh... (1 Reply)
Discussion started by: racbern
1 Replies

4. Red Hat

"service" , "process" and " daemon" ?

Friends , Anybody plz tell me what is the basic difference between "service" , "process" and " daemon" ? Waiting for kind reply .. .. (1 Reply)
Discussion started by: shipon_97
1 Replies

5. UNIX for Advanced & Expert Users

Why the nohup-ed background process always is "stopped" ?

I let a script A call script B. I used nohup a.sh &>/tmp/log & In script A it calls B directly, without any redirecting or nohup or background. However A is always "Stopped", while B is running correctly. Anybody knows why? thanks! -----Post Update----- BTW, if I don't use nohup... (1 Reply)
Discussion started by: meili100
1 Replies

6. Shell Programming and Scripting

Why the nohup-ed background process always is "stopped" ?

I let a script A call script B. I used nohup a.sh &>/tmp/log & In script A it calls B directly, without any redirecting or nohup or background. However A is always "Stopped", while B is running correctly. Anybody knows why? thanks! -----Post Update----- BTW, if I don't use nohup... (4 Replies)
Discussion started by: meili100
4 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
nagios3stats(8) 						      nagios							   nagios3stats(8)

NAME
nagios3stats - report statistics information from the nagios system SYNOPSIS
nagios3stats [-hVL] [-c config] [-m] [-d] DESCRIPTION
nagios3stats Is a program designed to provide information on the running nagios system. It can provide a brief summary of information, or it can be used to export specific information about the nagios system into an MRTG-compatible format. For more information please consult the nagios online documentation available at http://www.nagios.org or the documentation available with your nagios server's web page. OPTIONS
-c|--config=FILE The main configuration file. On debian systems this defaults to /etc/nagios3/nagios.cfg -m|--mrtg Print output in MRTG-compatible format. For more details run nagios3stats with --help -d|--data=VARS Comma-seperated list of variables to output in MRTG format. For more details run nagios3stats with --help. -h|--help A helpful usage message -V|--version Print version information -L|--license Print license details FILES
/etc/nagios3 Default configuration directory for nagios3 AUTHOR
nagios3 is written and maintained by Ethan Galstad <nagios@nagios.org>. This manual page was written by sean finney <seanius@debian.org> for the Debian GNU/Linux operating system (but it may be freely used, modified, and redistributed by others). sean finney February 2006 nagios3stats(8)
All times are GMT -4. The time now is 08:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy