I need a way to get the Process ID of the last command I executed in a script. Not the last background process but the last command.
For example, suppose I am executing a binary inside a script like so.
binary.program argument1 argument2
If this binary program runs fast, is there a command that will tell me the last PID of that command. In other words, can I get the PID of a command I execute within a shellscript? Is my only alternative to get information like this by running the process in the background and using "$!"?
while binary is nothing but, endless loop
Run it as,
strace zsh script.zsh > out.log 2>&1
And now in the out.log strace would have traced system call of the script which spawned the binary within it, it would be available as the return value of clone system call.
In the out.log it should be something like,
Return value above is the pid of the binary ( child ) spawned by the script ( parent )
I like your alternative, however I unfortunately need to make this work on HP-UX out of the box. So I do not have trace or tusc available on this server so I cannot use this method. Thanks for the reply, I will keep digging and see if I can find another solution. Thanks again.
Well, tusc is not default, it is something that has to be installed extra. I am not a sysadmin on this box so I cannot make the call of adding it. Since what I was trying to do would go elsewhere, I have to also assume the HP-UX box sitting elsewhere would also not have tusc installed.
Team,
I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list.
How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Hi,
I am running below code:
for i in `ls`
do
nohup sqlldr userid=apps/apps data=data01.dat log=my1.log control=my.ctl bad=my1.bad direct=yes silent=all parallel=true &
done
This will run the sqlldr command in parallel as a background process.
I want to store the process Id each... (7 Replies)
Dear all
Here is my command in my ksh script:
ftp ${ftpParameter} ${serverName} 2>&1 <${ftpScriptFile} |tee -a $LOG_FILE &
ftpPid=$!
wait
Due to server problem,the server accepts the connection and then do nothing,it makes the above script hang, is it possible to set time out for ftp... (1 Reply)
Hello folks,
I am tracking a process httpd only. But when i am grepping it, it is returning me multiple process of httpd, second it is showing another process of monitorix-httpd. Below commands i have tried.
Current output
# ps ax |grep http
929 ? Ss 0:00 monitorix-httpd... (5 Replies)
Hello
I'm using GNU screen for an application that I'm making. I will try to explain:
This application opens 2 screen session, A and B. Screen session A has a script running in teh first window. I want to be able to switch from screen session A to screen session B, from the script running in... (1 Reply)
I am trying to access batch process that take place each nite. I am using Solaris 5.8 (and i am used to redhat). however I am trying to access say a certain directory.
The home/oradev , is the directory...in there i am trying to access say a batch file within this, how can see if they are in... (1 Reply)