Skip to content
Snippets Groups Projects
Commit 9e43d640 authored by Marco Malavolti's avatar Marco Malavolti
Browse files

Fixed CRON job & log

parent 9ec9cbb3
No related branches found
No related tags found
No related merge requests found
...@@ -191,6 +191,8 @@ Note: Pay attetion on the chromedriver version: ...@@ -191,6 +191,8 @@ Note: Pay attetion on the chromedriver version:
* `crontab -e` * `crontab -e`
```bash ```bash
SHELL=/bin/bash
0 4 * * * /bin/bash $HOME/eccs2/cleanAndRunEccs2.sh > $HOME/eccs2/logs/eccs2cron.log 2>&1 0 4 * * * /bin/bash $HOME/eccs2/cleanAndRunEccs2.sh > $HOME/eccs2/logs/eccs2cron.log 2>&1
``` ```
......
#!/bin/bash #!/bin/bash
source $HOME/.bash_profile
# logs/stderr_$date.log is kept to see which IdP had been errors # logs/stderr_$date.log is kept to see which IdP had been errors
BASEDIR=$HOME BASEDIR=$HOME
# Remove old IdP and Fed List # Remove old IdP and Fed List
rm -f $BASEDIR/eccs2/input/*.json #rm -f $BASEDIR/eccs2/input/*.json
# Run ECCS2 # Run ECCS2
$BASEDIR/eccs2/runEccs2.py #$BASEDIR/eccs2/runEccs2.py
# Run Failed Command again # Run Failed Command again
bash $BASEDIR/eccs2/logs/failed-cmd.sh bash $BASEDIR/eccs2/logs/failed-cmd.sh
...@@ -21,34 +23,44 @@ suffix="'" ...@@ -21,34 +23,44 @@ suffix="'"
eccs2output="$BASEDIR/eccs2/output/eccs2_$date.log" eccs2output="$BASEDIR/eccs2/output/eccs2_$date.log"
declare -a eccs2cmdToRemoveArray declare -a eccs2cmdToRemoveArray
while IFS= read -r line if [ -s $file ]; then
do
string=$line while IFS= read -r line
do
string=$line
#remove "prefix" from the command string at the beginning. #remove "prefix" from the command string at the beginning.
prefix_removed_string=${string/#$prefix} prefix_removed_string=${string/#$prefix}
#remove "suffix" from the command string at the end. #remove "suffix" from the command string at the end.
suffix_removed_string=${prefix_removed_string/%$suffix} suffix_removed_string=${prefix_removed_string/%$suffix}
entityIDidp=$(echo "$suffix_removed_string" | jq '.entityID') entityIDidp=$(echo "$suffix_removed_string" | jq '.entityID')
#remove start and end quotes from the entityIDidp to be able to use "grep" #remove start and end quotes from the entityIDidp to be able to use "grep"
entityIDidp="${entityIDidp:1}" entityIDidp="${entityIDidp:1}"
entityIDidp="${entityIDidp%?}" entityIDidp="${entityIDidp%?}"
result=$(grep $entityIDidp $eccs2output | wc -l) result=$(grep $entityIDidp $eccs2output | wc -l)
if [[ "$result" = 1 ]]; then if [[ "$result" = 1 ]]; then
eccs2cmdToRemoveArray+=("$entityIDidp") eccs2cmdToRemoveArray+=("$entityIDidp")
else else
echo "The result for the IdP '$entityIDidp' has been found multiple times on $eccs2output. It is wrong." echo "The result for the IdP '$entityIDidp' has been found multiple times on $eccs2output. It is wrong."
fi fi
done <"$file" done <"$file"
# Remove IdP command that had success from "failed-cmd.sh"
for idpToRemove in ${eccs2cmdToRemoveArray[@]} # Remove IdP command that had success from "failed-cmd.sh"
do for idpToRemove in ${eccs2cmdToRemoveArray[@]}
$(grep -v $idpToRemove $file > temp ; mv -f temp $file) do
done $(grep -v $idpToRemove $file > temp ; mv -f temp $file)
done
fi
if [ -s $file ]; then
echo "$date - ECCS2 NOT OK: Some eduGAIN IdPs have remained unchecked. See the 'logs/failed-cmd.sh' and logs/stderr_$date.log files"
else
echo "$date - ECCS2 OK: All eduGAIN IdPs have been checked successfully"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment