-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_ss12000.sh
executable file
·39 lines (31 loc) · 1.32 KB
/
run_ss12000.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Check if another instance of the script is already running
if pgrep -f "imcode_ss12000.pl" > /dev/null; then
echo "$(date '+%Y-%m-%d %H:%M:%S') : Script is already running. Exiting."
exit 1
fi
# Record the start time of script execution
start_time=$(date +%s)
i=1
while true; do
# Check the elapsed time
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -gt 28800 ]; then # 4 hours = 4 * 3600 seconds = 14400, 8h = 28800
echo "$(date '+%Y-%m-%d %H:%M:%S') : Script has been running for more than 8 hours. Forcing termination."
exit 1
fi
echo "$(date '+%Y-%m-%d %H:%M:%S') : Running iteration $i"
output=$(timeout 10m sudo koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/imcode_ss12000.pl 2>&1)
if echo "$output" | grep -q "EndLastPageFromAPI"; then
echo "$(date '+%Y-%m-%d %H:%M:%S') : Received 'EndLastPageFromAPI'. Exiting loop."
break
fi
if echo "$output" | grep -q "ErrorVerifyCategorycodeBranchcode"; then
echo "$(date '+%Y-%m-%d %H:%M:%S') : Received 'ErrorVerifyCategorycodeBranchcode'. Exiting loop."
break
fi
echo "$(date '+%Y-%m-%d %H:%M:%S') : Iteration $i completed"
i=$((i+1))
done