1753789 Members
7508 Online
108799 Solutions
New Discussion юеВ

Re: Mail

 
SOLVED
Go to solution
Allanm
Super Advisor

Mail

I do a deployment each week in the following fashion using a for loop :

===================
for s in $servers

do

cd /d/$s/

nohup ./cbo.install < /dev/null &

done
=================

how do I make it mail me a notification once its done.

Thanks,
Allan.
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: Mail

You could add:
echo "Process complete" | mailx -s "Done with XYX" Allan.m@bar.com
James R. Ferguson
Acclaimed Contributor

Re: Mail

Hi Allan:

If you want to wait until the last process is done before sending your notification, do:

#/usr/bin/sh
for s in $servers
do
cd /d/$s/
nohup ./cbo.install < /dev/null &
LAST=$!
done
wait ${LAST}
echo "Process complete" | mailx -s "Done with XYX" Allan.m@bar.com

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor
Solution

Re: Mail

HI (again) Allan:

I should hasten to add that in the suggestion I made to wait until the last process completes before sending a mail notification, "last" assumed that all processes complete in order. This is unlikely.

We can wait for all processes by simply doing:

#/usr/bin/sh
for s in $servers
do
cd /d/$s/
nohup ./cbo.install < /dev/null &
done
wait #...for all children...
echo "Process complete" | mailx -s "Done with XYX" Allan.m@bar.com

Regards!

...JRF...