T06 · System Persistence
- Location
scripts/restore_context.py:2160- Finding
Recurring Cron-Based Context Monitor Establishes Cross-Session Persistence
- Content
View full analysis
str: """ Generate a shell script for cron integration. Creates a ready-to-use cron entry script that can be added to crontab for automated context monitoring. """ script = f'''#!/bin/bash # Context Restore Auto-Monitor # Generated by restore_context.py Phase 3 # # Add to crontab for automatic context monitoring: # */5 * * * * /home/athur/.openclaw/workspace/skills/context-restore/scripts/auto_context_monitor.sh >> /var/log/context_monitor.log 2>&1 SCRIPT_DIR="/home/athur/.openclaw/workspace/skills/context-restore/scripts" CONTEXT_FILE="/home/athur/.openclaw/workspace/compressed_context/latest_compressed.json" LOG_FILE="/home/athur/.openclaw/workspace/logs/context_monitor.log" mkdir -p "$(dirname "$LOG_FILE")" echo "[$(date '+%Y-%m-%d %H:%M:%S')] Running context check..." python3 "$SCRIPT_DIR/restore_context.py" --auto --quiet --level normal ''' return script def install_cron_job( script_path: str = None, interval_minutes: int = 5 ) -> bool: if script_path is None: script_path = os.path.join(SCRIPT_DIR, 'auto_context_monitor.sh') script_content = generate_cron_script() try: with open(script_path, 'w', encoding='utf-8') as f: f.write(script_content) os.chmod(script_path, 0o755) interval = f"*/{interval_minutes}" if interval_minutes < 60 else f"0 */{interval_minutes // 60}" cron_entry = f"{interval} * * * * {script_path}" print(f"{EMOJI['success']} Cron script created: {script_path}") print(f"{EMOJI['info']} To install, run:") print(f' echo "{cron_entry}" ...[truncated 2737 chars]- Remediation
View remediation
