Skip to content

Commit 2c461aa

Browse files
Removal of Cron Jobs with Timeout
Modified code that removes cron jobs from 3rd-party add-ons so that the cru command call has a timeout to prevent a stuck commands.
1 parent 73d88a5 commit 2c461aa

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎MerlinAU.sh‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2026-Jun-23
7+
# Last Modified: 2026-Jul-30
88
###################################################################
99
set -u
1010

1111
## Set version for each Production Release ##
1212
readonly SCRIPT_VERSION=1.6.6
13-
readonly SCRIPT_VERSTAG="26073010"
13+
readonly SCRIPT_VERSTAG="26073018"
1414
readonly SCRIPT_NAME="MerlinAU"
1515
## Set to "master" for Production Releases ##
1616
SCRIPT_BRANCH="dev"
@@ -8852,24 +8852,48 @@ _Toggle_FW_UpdateCheckSetting_()
88528852
}
88538853

88548854
##----------------------------------------##
8855-
## Modified by Martinski W. [2025-Feb-22] ##
8855+
## Modified by Martinski W. [2026-Jul-30] ##
88568856
##----------------------------------------##
88578857
_RemoveCronJobsFromAddOns_()
88588858
{
8859-
eval $cronListCmd | grep -E "$cronJobsRegEx1|$cronJobsRegEx2|$cronJobsRegEx3|cronJobsRegEx4|$cronJobsRegEx5|$cronJobsRegEx6" > "$addonCronJobList"
8859+
eval $cronListCmd | grep -E "$cronJobsRegEx1|$cronJobsRegEx2|$cronJobsRegEx3|$cronJobsRegEx4|$cronJobsRegEx5|$cronJobsRegEx6" > "$addonCronJobList"
88608860
if [ ! -s "$addonCronJobList" ]
88618861
then
88628862
rm -f "$addonCronJobList"
88638863
Say "Cron jobs from 3rd-party add-ons were not found."
88648864
return 1
88658865
fi
88668866

8867+
_RemoveCronJobWithTimeout_()
8868+
{
8869+
local cruProcID cruProcOK=false
8870+
local waitSecsMAX=10 waitSecsCNT=0
8871+
8872+
cru d "$1" & cruProcID="$!"
8873+
8874+
while [ "$waitSecsCNT" -lt "$waitSecsMAX" ]
8875+
do
8876+
sleep 1
8877+
waitSecsCNT="$((waitSecsCNT + 1))"
8878+
if ! kill -EXIT "$cruProcID" 2>/dev/null
8879+
then cruProcOK=true ; break
8880+
fi
8881+
done
8882+
8883+
if kill -EXIT "$cruProcID" 2>/dev/null
8884+
then
8885+
kill -9 "$cruProcID"
8886+
Say "Wait Timeout [$waitSecsMAX secs] for CRU command expired."
8887+
fi
8888+
}
8889+
88678890
local cronJobCount=0 cronJobIDx cronJobCMD
88688891

88698892
while read -r cronJobLINE
88708893
do
88718894
if [ -z "$cronJobLINE" ] || echo "$cronJobLINE" | grep -qE "^[[:blank:]]*#"
8872-
then continue ; fi
8895+
then continue
8896+
fi
88738897
cronJobCount="$((cronJobCount + 1))"
88748898

88758899
[ "$cronJobCount" -eq 1 ] && \
@@ -8881,7 +8905,7 @@ _RemoveCronJobsFromAddOns_()
88818905

88828906
if [ -n "$cronJobIDx" ]
88838907
then
8884-
cru d "$cronJobIDx" ; sleep 1
8908+
_RemoveCronJobWithTimeout_ "$cronJobIDx"
88858909
if eval $cronListCmd | grep -qE "#${cronJobIDx}#$"
88868910
then Say "**ERROR**: Failed to remove cron job [$cronJobIDx]."
88878911
else Say "Cron job [$cronJobIDx] was removed successfully."

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
22

3-
## v1.6.5
4-
## 2026-June-23
3+
## v1.6.6
4+
## 2026-Jul-30
55

66
## WebUI:
77
<img width="775" height="1640" alt="image" src="https://github.com/user-attachments/assets/846f889b-b39f-4ffe-a37a-8892ad9b2f7f" />

‎version.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.5
1+
1.6.6

0 commit comments

Comments
 (0)