Unix Programming - how to check whether a process has completed or not

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > how to check whether a process has completed or not





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author how to check whether a process has completed or not
star

2006-04-02, 7:41 pm

am scheduling a process through crontab and i have to start another
process once this first process gets completed... how to check whether
the first process has got completed or not... can anybody help me
regarding this..
Thanks Star

Nils O. Selåsdal

2006-04-02, 7:41 pm

star wrote:
> am scheduling a process through crontab and i have to start another
> process once this first process gets completed... how to check whether
> the first process has got completed or not... can anybody help me
> regarding this..
> Thanks Star

Rather than running the process directly from cron, run a shell script
that reads e.g.

#!/bin/sh
command1
command2
Thobias Vakayil

2006-04-02, 7:41 pm

star wrote:

> am scheduling a process through crontab and i have to start another
>process once this first process gets completed... how to check whether
>the first process has got completed or not... can anybody help me
>regarding this..
>Thanks Star
>
>
>

use ps command to get the list of process and grep the particular job.
If it's not present then start the next job.
Regards,

Thobias Vakayil

Norm Dresner

2006-04-02, 7:41 pm

"Thobias Vakayil" <Vakayil.Thobias@alcatel.com> wrote in message
news:44227B1F.7040304@alcatel.com...
| star wrote:
|
| > am scheduling a process through crontab and i have to start another
| >process once this first process gets completed... how to check whether
| >the first process has got completed or not... can anybody help me
| >regarding this..
| >Thanks Star
| >
| >
| >
| use ps command to get the list of process and grep the particular job.
| If it's not present then start the next job.
| Regards,
|
| Thobias Vakayil

Better check to see that the fist job has started before checking to see
that it's finished. It's possible that scheduling of higher priority tasks
could delay the first one.

Norm

Pankaj Munjal

2006-04-02, 7:41 pm


Norm Dresner wrote:
> "Thobias Vakayil" <Vakayil.Thobias@alcatel.com> wrote in message
> news:44227B1F.7040304@alcatel.com...
> | star wrote:
> |
> | > am scheduling a process through crontab and i have to start another
> | >process once this first process gets completed... how to check whether
> | >the first process has got completed or not... can anybody help me
> | >regarding this..
> | >Thanks Star
> | >
> | >
> | >
> | use ps command to get the list of process and grep the particular job.
> | If it's not present then start the next job.
> | Regards,
> |
> | Thobias Vakayil
>
> Better check to see that the fist job has started before checking to see
> that it's finished. It's possible that scheduling of higher priority tasks
> could delay the first one.
>
> Norm




Hi,

Other possible way could be, you can redirect the output following
command to a file and check if value exists then process is running
else process has been stopped:

ps -aefux | grep sc | grep <path for executable file> | awk '{print
$2}'


Thanks

Pankaj Munjal

Martin Blume

2006-04-02, 7:41 pm

"Nils O. Selåsdal" schrieb
> Rather than running the process directly from cron,
> run a shell script that reads e.g.
>
> #!/bin/sh
> command1
> command2
>


Or, if command2 needs to run only if command1 has
succeeded:

#!/bin/sh
command1 && command2

HTH
Martin


Michael Paoli

2006-04-02, 7:41 pm

star wrote:
> am scheduling a process through crontab and i have to start another
> process once this first process gets completed... how to check whether
> the first process has got completed or not... can anybody help me


#include <sys/types.h>
#include <signal.h>
main(){
/* initialize pid */
if(kill(pid,0)){
/* this process cannot signal pid - it may no longer exist */
}
else{
/* pid exists and this process can signal it */
}
}

references/excerpts:
cc(1)
kill(2)

"Answers"/replys can and will be context (group) sensetive.

Crosspost, don't multi-post.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com