Refactor A72_alarm_getter.sh script for improved readability and reliability
- Removed unnecessary variable interpolation in the 'echo' statement. - Changed the path for 'atq' and 'atrm' commands to use the full path. - Updated the 'ping' command to use the full path for better compatibility. - Added comments and improved formatting for better script understanding.
This commit is contained in:
parent
63720dafea
commit
a0dbcefb1c
@ -8,17 +8,18 @@
|
|||||||
# dann das Einschalten der Lichter.
|
# dann das Einschalten der Lichter.
|
||||||
# mit dem "at" Befehl.
|
# mit dem "at" Befehl.
|
||||||
|
|
||||||
echo "Ausgeführt um: $date"
|
echo "Ausgeführt um: "
|
||||||
|
date
|
||||||
|
|
||||||
# Überprüfen, ob alte "at"-Aufträge abgelaufen sind und sie löschen
|
# Überprüfen, ob alte "at"-Aufträge abgelaufen sind und sie löschen
|
||||||
delete_expired_at_jobs() {
|
delete_expired_at_jobs() {
|
||||||
current_time=$(date +"%Y-%m-%d %H:%M:%S")
|
current_time=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
old_jobs=$(atq | awk -v current_time="$current_time" '$3 < current_time { print $1 }')
|
old_jobs=$(/usr/bin/atq | awk -v current_time="$current_time" '$3 < current_time { print $1 }')
|
||||||
|
|
||||||
if [ -n "$old_jobs" ]; then
|
if [ -n "$old_jobs" ]; then
|
||||||
echo "Lösche überholte 'at'-Jobs:"
|
echo "Lösche überholte 'at'-Jobs:"
|
||||||
for job_id in $old_jobs; do
|
for job_id in $old_jobs; do
|
||||||
atrm "$job_id"
|
/usr/bin/atrm "$job_id"
|
||||||
echo "Gelöscht: $job_id"
|
echo "Gelöscht: $job_id"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
@ -45,7 +46,7 @@ weckzeit_datei="/root/iobroker_scripts/generel/.weckzeiten.txt"
|
|||||||
# Überprüfen, ob das Ziel über Ping erreichbar ist
|
# Überprüfen, ob das Ziel über Ping erreichbar ist
|
||||||
function is_target_reachable() {
|
function is_target_reachable() {
|
||||||
echo "teste ping $A72_ip"
|
echo "teste ping $A72_ip"
|
||||||
local ping_output=$(ping -q -w 3 -c 3 $A72_ip 2>&1)
|
local ping_output=$(/bin/ping -q -w 3 -c 3 $A72_ip 2>&1)
|
||||||
local ping_exit_code=$?
|
local ping_exit_code=$?
|
||||||
|
|
||||||
echo "$ping_output" # Ausgabe des Ping-Befehls anzeigen
|
echo "$ping_output" # Ausgabe des Ping-Befehls anzeigen
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user