Fixed AT Terminal state sessions and shedule cell locking bugs.
This commit is contained in:
@@ -42,16 +42,33 @@ fi
|
||||
# Fix the spacing in the cron line to ensure exactly 5 fields
|
||||
CRON_LINE="0 0 * * * $SCRIPT_PATH"
|
||||
|
||||
# Install crontab if not already present
|
||||
# Install crontab while preserving other entries
|
||||
if ! crontab -l | grep -Fq "$SCRIPT_PATH"; then
|
||||
# Get existing crontab - ensuring clean formatting
|
||||
(crontab -l 2>/dev/null | grep -v "$SCRIPT_PATH" || true; echo "$CRON_LINE") | crontab -
|
||||
if [ $? -eq 0 ]; then
|
||||
# Create temporary file
|
||||
TEMP_CRON=$(mktemp)
|
||||
|
||||
# Get existing crontab
|
||||
crontab -l 2>/dev/null > "$TEMP_CRON" || true
|
||||
|
||||
# Remove any old instances of this script
|
||||
if [ -s "$TEMP_CRON" ]; then
|
||||
sed -i "\#$SCRIPT_PATH#d" "$TEMP_CRON"
|
||||
fi
|
||||
|
||||
# Add new cron line
|
||||
echo "$CRON_LINE" >> "$TEMP_CRON"
|
||||
|
||||
# Install new crontab
|
||||
if crontab "$TEMP_CRON"; then
|
||||
logger -t log_cleanup "Successfully installed crontab job"
|
||||
else
|
||||
logger -t log_cleanup "Failed to install crontab job"
|
||||
rm -f "$TEMP_CRON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
rm -f "$TEMP_CRON"
|
||||
fi
|
||||
|
||||
# Clean log files
|
||||
|
||||
Reference in New Issue
Block a user