Skip to content

Commit 8a6ea3e

Browse files
committed
RDKB-63303, RDKB-63414, RDKB-63743 : Move RdkLogger Scripts to Cron
Reason for change: Running the rdklogger scripts as cron jobs instead of background processes when the cron is enabled and running as normal background process when the cron is disabled. Test Procedure: Check scripts are running in crontab when the cron is enabled. Priority: P1 Risks: None Signed-off-by: KavyaChowdahalli_Suresh@comcast.com
1 parent 5ee49c9 commit 8a6ea3e

3 files changed

Lines changed: 1718 additions & 689 deletions

File tree

fileUploadRandom.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ if [ ! -d "$FILEUPLOAD_TMP_DIR" ]; then
4545
mkdir -p "$FILEUPLOAD_TMP_DIR"
4646
fi
4747

48+
rdklogger_cron_enable=`syscfg get RdkbLogCronEnable`
49+
if [ "$rdklogger_cron_enable" = "true" ]; then
50+
CRON_MODE=1
51+
LOCKFILE="/tmp/randomfile_cron.lock"
52+
if [ -f "$LOCKFILE" ]; then
53+
old_pid=$(cat "$LOCKFILE" 2>/dev/null)
54+
if [ -n "$old_pid" ] && kill -0 "$old_pid" 2>/dev/null; then
55+
echo_t "Already a cron instance is running for fileUploadRandom file; No 2nd instance"
56+
exit 0
57+
fi
58+
rm -f "$LOCKFILE"
59+
fi
60+
echo $$ > "$LOCKFILE"
61+
cleanup() { rm -f "$LOCKFILE"; }
62+
trap cleanup EXIT
63+
fi
64+
4865
generate_random_delay()
4966
{
5067
rand_hr=0
@@ -90,7 +107,6 @@ calcRandTimeandUpload()
90107

91108
if [ "$remaining" -le 300 ]; then
92109
echo_t "fileupload_random: Sleeping $remaining seconds now" >> "$NEXT_UPLOAD_TIME_FILE"
93-
rm -f "$DELAY_REMAINING_FILE" "$HEARTBEAT_TICK_FILE"
94110
delay_completed=1
95111
[ "$remaining" -gt 0 ] && sleep "$remaining"
96112
else
@@ -246,6 +262,9 @@ calcRandTimeandUpload()
246262
fi
247263

248264
createSysDescr
265+
if [ "$CRON_MODE" = "1" ]; then
266+
rm -f "$DELAY_REMAINING_FILE" "$HEARTBEAT_TICK_FILE"
267+
fi
249268
}
250269

251270

0 commit comments

Comments
 (0)