Sponsored Content
Top Forums Shell Programming and Scripting How to get the parent PID only in Solaris? Post 303020937 by MadeInGermany on Tuesday 31st of July 2018 01:41:22 PM
Old 07-31-2018
I made some experiments, and indeed Solaris has always put the oldest process last.
Implementation proposal:
Code:
lastarg(){
  [ $# -gt 0 ] && (set -f; eval echo "\${$#}")
}
fuser_result=`fuser -f /web/"$1"/admin-*/logs/access 2>/dev/null`
fuser_result=`lastarg $fuser_result`

 

10 More Discussions You Might Find Interesting

1. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

2. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

3. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

4. Shell Programming and Scripting

parent shell pid

hi folks can any suggest me how to get a parent processid in the script if i am executing this in the script vi myscript.sh echo "parent shell pid"$$ sh myscript.sh but when i am executing this i am getting a new pid(actually that is the child pid) whenever i am executing this... (4 Replies)
Discussion started by: maheshwin
4 Replies

5. Shell Programming and Scripting

Environment Variable Parent PID

I have always used the "$$" environment variable to find the current process number. Is there any similar way or perhaps something else to easily find the parent process number? I realize I could do something like ps and grep for the process and cut or awk out the parent process but I wanted to... (1 Reply)
Discussion started by: scotbuff
1 Replies

6. Shell Programming and Scripting

full path of a file situated either in parent's dir. or parent's parent dir. so on...

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies

7. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

8. Shell Programming and Scripting

how to grep parent process PID in shell scripting

hi all, for an example: $ ps -ef | grep apache | awk '{ print $2, $3 }' 24073 11784 28021 1 28022 1 28038 1 28041 28040 28045 28041 28047 28041 28040 1 28049 28041 28051 28041 28053 28041 28030 1 28054 28041 28055 28041 28056 28041 28057 28041 (5 Replies)
Discussion started by: raghur77
5 Replies

9. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

10. UNIX for Beginners Questions & Answers

Trying to debug truss command of PID in Solaris 10.

I'm getting the following output from a truss operation of a PID from an application that will not start properly, something with the writing to an archive. Here is the output: open("arch/chkpt.arch", O_RDWR) Err#13 EACCES open("arch/chkpt.arch", O_RDWR|O_CREAT|O_TRUNC, 0666)... (6 Replies)
Discussion started by: chadpierce62
6 Replies
PIDOF(8)						Linux System Administrator's Manual						  PIDOF(8)

NAME
pidof -- find the process ID of a running program. SYNOPSIS
pidof [-s] [-c] [-n] [-x] [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] program [program..] DESCRIPTION
Pidof finds the process id's (pids) of the named programs. It prints those id's on the standard output. This program is on some systems used in run-level change scripts, especially when the system has a System-V like rc structure. In that case these scripts are located in /etc/rc?.d, where ? is the runlevel. If the system has a start-stop-daemon (8) program that should be used instead. OPTIONS
-s Single shot - this instructs the program to only return one pid. -c Only return process ids that are running with the same root directory. This option is ignored for non-root users, as they will be unable to check the current root directory of processes they do not own. -n Avoid stat(2) system function call on all binaries which are located on network based file systems like NFS. Instead of using this option the the variable PIDOF_NETFS may be set and exported. -x Scripts too - this causes the program to also return process id's of shells running the named scripts. -o omitpid Tells pidof to omit processes with that process id. The special pid %PPID can be used to name the parent process of the pidof pro- gram, in other words the calling shell or shell script. EXIT STATUS
0 At least one program was found with the requested name. 1 No program was found with the requested name. NOTES
pidof is actually the same program as killall5; the program behaves according to the name under which it is called. When pidof is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it is possible that it returns pids of running programs that happen to have the same name as the program you're after but are actually other programs. Note that that the executable name of running processes is calculated with readlink(2), so symbolic links to executables will also match. SEE ALSO
shutdown(8), init(8), halt(8), reboot(8), killall5(8) AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl 01 Sep 1998 PIDOF(8)
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy