how to know that a perticular process is started!!!


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users how to know that a perticular process is started!!!
# 1  
Old 05-13-2007
how to know that a perticular process is started!!!

Hi all,

I wanted a write a script which will start executing whenever a particular process will starts running in a background.
Is there is any way in Unix if a directory contents changed then a signal/Interrupt will generated and by taking status of that interrupt I can execute some scripts.
Please provide your ideas and solution if any...

Thanks...
# 2  
Old 05-13-2007
More recent Linux kernels provide change-notify information for directories.

What platform/OS?
# 3  
Old 05-13-2007
>What platform/OS?

HP-UX B.11.11
# 4  
Old 05-14-2007
I think we can do this simply by keeping our eye on the Process Status table, where particular process id is generated for the processes.
By that we can check the parent or child process has been started or not and accordingly we can react on that.
Each process has a process id, its status (R/Z/O/S), and name of the process.
I think this idea will work, but ofcourse we have to monitor the ps table closely.

Thanks
# 5  
Old 05-14-2007
>I think we can do this simply by keeping our eye on the Process Status table, where particular process id is generated for the processes.

Yes this can be a solution that I thought, but this is not a efficient way to run a program continuously to see the status of other required process.
I want a interrupt/signaling mechanism which will trigger my script when a particular process get started.

Is there any way to see the process execution log so at least I can poll after a specific interval of time to that log and if I see the process is being executing or recently executed then I will trigger my script.

Thanks...
# 6  
Old 05-15-2007
Or why not go for a quick simple solution?

Aim: to run program B whenever program A is started....

Rename A to A.orig

create a file called A as follows...

Code:
#!/bin/sh
B $$ </dev/null 1>/dev/null 2>&1 &
exec A.orig $@

It will even give you the pid of the program as an argument.

Last edited by porter; 05-18-2007 at 04:54 PM..
# 7  
Old 05-17-2007
Code:
#!/bin/sh
B $$ >/dev/null 1>/dev/null 2>&1 &
exec A.orig $@

It will even give you the pid of the program as an argument.[/QUOTE]

------------------------------------------------------------------------

what does the second line does here....can you explain.

thx
bishweshwar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Can someone summarize what exactly this perticular code is doing

#include<stdio.h> #include<string.h> int main() { char a={0,1,2,3,4,5,6,7,8,9}; printf("\n--%s-- unable to access values",a); printf("\n--%d %d-- able to access through direct acess",a,a); printf("\n--%d-- but the failing to read the size\n",strlen(a)); return 0; } (2 Replies)
Discussion started by: hk108
2 Replies

2. Shell Programming and Scripting

how to check whether a process started at particular time

I want to check whether a particular process has started at 10:00a.m or not. I can check process by ps -fu but dont know how to check it with respect to time. Could anyone help me with this? ---------- Post updated at 11:14 AM ---------- Previous update was at 10:52 AM ---------- can i use... (9 Replies)
Discussion started by: kishore kumar
9 Replies

3. Shell Programming and Scripting

stopping process started with "while"

Hello unix forum ! how do i get rid of this while thing ? if started some where by crontab for example. while ; do ./script > /dev/null ; done & or for example if in terminal while ; do ./script ; done & and the script is outputing and I can't write commands. other... (2 Replies)
Discussion started by: max_475
2 Replies

4. Red Hat

Killing child daemon started by parent process

Hi All, Hope this is right area to ask this question. I have a shell script (bash) "wrapper.sh", which contains few simple shell command which executes a "server.sh" (conatins code to execute a java server) as a daemon. Now what I want to kill this "server.sh" so that the server should... (2 Replies)
Discussion started by: jw_amp
2 Replies

5. Shell Programming and Scripting

Process id of the exe started with nohup

Hi, I have a strange problem. In my shell script, i am startting another program (a c++ exe) with nohup . I am getting the process id of this started process with using $! I am writing this process id into another file so that i can keep checking for this process ids to check whether the... (2 Replies)
Discussion started by: parvathi_rd
2 Replies

6. Shell Programming and Scripting

How to get rid of message when script kills process it started?

When I run the following script I get the following error message whcih I would like to suppress when the kill is issued: ./kill.sh: line 13: 31854 Killed nc -l -p 12345 Script: #!/bin/bash echo running nc in the background nc -l -p 12345 & PID=$! echo nc pid: $PID ... (1 Reply)
Discussion started by: cmarkle
1 Replies

7. UNIX for Dummies Questions & Answers

Process started on console

Please can someone describe what causes undesired process startup on system console. ps -ef output is like: root 1763 1 0 16:22:24 console 0:00 /bin/sh /usr/System........ process is blocking system console for any access (2 Replies)
Discussion started by: zverzak
2 Replies

8. Programming

Child process is not getting started

Hi, When i m trying to run below code,its entering into wait stage. output: In parent pid=2134 // some random value assigned to child process parent waiting..... and then it keeps on waiting for child to get terminate Y this child is not getting... (5 Replies)
Discussion started by: Crab
5 Replies

9. UNIX for Dummies Questions & Answers

is there any way to know how much time process was running from the moment it started

i have process that was started few days ago , is there way to know by its id how long it was alive in the system ? Thanks (2 Replies)
Discussion started by: umen
2 Replies

10. Shell Programming and Scripting

PID of process started in background??

I am having a problem getting the PID of a process I start in the background is a csh. In tcsh and sh it's simple $! give it to you But in csh this just returns Variable syntax From the man page it should work but it doesn't???? Any help. (2 Replies)
Discussion started by: stilllooking
2 Replies
Login or Register to Ask a Question