I am database guy and not very good at shell scripts. I am seeking help to sharp my script coding. I have 5 scripts
1. master script. I use this one to call other four scripts to do database work.
2. db_backup_1 and log_backup_1
3. db_backup_2 and log_backup_2
in master script, I want to call db_backup_1 first. If this one run successfully, then server return 0, then invoke log_backup_1. If it failed, return 1, a email will be sent to me.
Then sleep 30 seconds
invoke db_backup_2, if it is succesul, return 0, invoke log_backup_2. If failed, return 1, another email will be sent to me.
My initial code like this. I know it must contains problems. I seek guru to help me to sharp this piece of code and make it work. Then I will do my test.
#!/bin/ksh
./db_backup_1.sh &
pid_db_backup_1=$!
wait $pid_db_backup_1
echo "db_backup_1 returned $?"
If ["$?" -eq "0" ]; then
./log_backup_1.sh &
else
mail -s 'db_backup_1 Unsuccessful'
mymail@yahoo.com
fi
sleep 30
./db_backup_2.sh &
pid_db_backup_2=$!
wait $pid_db_backup_2
echo "db_backup_2 returned $?"
If ["$?" -eq "0" ]; then
./log_backup_2.sh &
else
mail -s 'db_backup_2 Unsuccessful'
mymail@yahoo.com
fi
exit 0
thank you for your help in advance.