Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am running 10 programs in UNIX environment. I run them by crontab. So far everything okay. Now my boss asked me to write a shell script so that I can run the first program, check error message from the first program log. If errors occured then stop and send an email message to my account. If no error then process to run second program, then check error message for second program, if no error then continue on, etc. Does anyone of you even write a script like this situation? I was told it is a common problem yet I could find any example. I appreciate any help or suggestions.
Thanks,
Vera.
e-mail: polanskyv@yahoo.com

Vera, there are many different approaches, and I would need more info before suggesting a solution. Is this a single cron job with 10 steps? And if so, does each program exit with a status code that could be checked with $?. If not, does each program write info to a log file that could be checked, and if so, would these be new log files for each run, or accumulative log files.
Assuming that there is a way to check success or failure of each program, then it should be a simple matter to prevent further processing and send an e-mail.

One simple way I can think is that....
Have a common log file.
Let first script enter its status of exit (say true/false or success/failure) appended by its own name.
Next would be, let the second script see the log file and see for success of the first script and if succes proceed.If its failure
put an entry as "end sent email" in the log file and send a unix mail to your account. After this further scripts will not run once they see "end send email".If this entry is not there , check for success/failure+second script name and proceed on the conditions.
This is like a cascading ( or hand shaking) senario.
I think it would help you atleast if others won't.
Thanks
Prithivi

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |