Hello,
I'm new of this forum and have very very old and rusty memories of shell scripting (my latest script dates back to about 20 years ago !).
My need is following:
I'm testing a software that make a backup, but at now is not implemented the email report (the sw is in beta).
I'm trying to write a script the extract job result and send me an email.
My problem is to check when the job is finished, in order to grep job result and email it. In other words, until the job is running do nothing; when job is ended,
proceed with the script.
Thanks to those who want to help me.
Davide
This is the script:
------------------------------------------------------------------------
#!/bin/bash
#
# Script to run Veeam backup and email job status (BackupJob3)
#This is the backup command
veeamconfig job start --id {ba6434ea-55cc-4529-a9d3-69ec868769e9}
JOBNAME=BackupJob3
export JOBNAME
TODAY=$(date +"%Y-%m-%d")
export TODAY
# this to check id job is running or not
JOBRUNNING=`pgrep veeamjobman`
export JOBRUNNING
#Here I need to check and wait for job ending, but the while cycle is not working
while [ -z "$JOBRUNNING" ]
do
echo "job is running" >> /tmp/test/out.txt
done
# this is to check if the job is failed or not
FAILED=`veeamconfig session list | grep -e Failed | grep $JOBNAME | grep $TODAY`
export FAILED
if [ -z "$FAILED" ]
then
echo "Job $JOBNAME Successfull" | mailx -s "VAL session $JOBNAME Successfull" my@email.it
else
echo "Job $JOBNAME Failed" | mailx -s "VAL session $JOBNAME Failed" my@email.it
fi
------------------------------------------------------------------------