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...
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.
>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.
the first line says this is a script to be run by /bin/sh
the second line says spawn program B but attach stdin, stdout and stderr to /dev/null so they don't affect the output of the current process, this process will spin off on it's merry way due to the "&", the "$$" will be replaced by the current process id. this is the program that says "A" is running and allows you to do your funky custom stuff here.
the third line says run the original program using the original arguments in this process so the process-id we gave out in line two is still the correct one.