From 142174ad0b2da02cb60dfe95b6b4da1f61870fd5 Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Wed, 17 Jul 2024 17:26:21 +0800 Subject: [PATCH 1/2] [INLONG-10645][Agent] Installer adds process protection --- inlong-agent/agent-installer/bin/crontab.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 inlong-agent/agent-installer/bin/crontab.sh diff --git a/inlong-agent/agent-installer/bin/crontab.sh b/inlong-agent/agent-installer/bin/crontab.sh new file mode 100644 index 00000000000..fbd1939b41c --- /dev/null +++ b/inlong-agent/agent-installer/bin/crontab.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +BASE_DIR=$(cd "$(dirname "$0")"/../;pwd) +cd $BASE_DIR + +LOG_DIR=${BASE_DIR}/logs/ + +CRON_CMD="*/5 * * * * (cd ${BASE_DIR};sh ./bin/installer.sh start > ${BASE_DIR}/logs/monitor.log 2>&1)" + +CRON_COUNT=`crontab -l | grep -Ew "${BASE_DIR}" | grep "^[^#+]" | wc -l` +if [ $CRON_COUNT -eq 0 ]; then + mkdir -p $LOG_DIR + CRON_TMP=${LOG_DIR}/crontab.tmp + crontab -l > $CRON_TMP + echo "${CRON_CMD}" >> $CRON_TMP + crontab $CRON_TMP +fi From fce13fc80b60a9dc29894ab669d038cf6ab98f90 Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Wed, 17 Jul 2024 17:36:48 +0800 Subject: [PATCH 2/2] [INLONG-10645][Agent] Installer adds process protection --- inlong-agent/agent-installer/bin/crontab.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/inlong-agent/agent-installer/bin/crontab.sh b/inlong-agent/agent-installer/bin/crontab.sh index fbd1939b41c..4ab4ab6f713 100644 --- a/inlong-agent/agent-installer/bin/crontab.sh +++ b/inlong-agent/agent-installer/bin/crontab.sh @@ -1,4 +1,20 @@ -#!/bin/sh +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# BASE_DIR=$(cd "$(dirname "$0")"/../;pwd) cd $BASE_DIR