# Cron Jobs Inventory - srv759970.hstgr.cloud
# Generated: 2025-12-09T17:45:00Z
# DEEP AUDIT - All cron jobs from all users

metadata:
  generated_at: "2025-12-09T17:45:00Z"
  server: srv759970.hstgr.cloud
  total_cron_jobs: 12
  users_with_cron: ["root", "automation"]

# =============================================================================
# ROOT CRONTAB
# =============================================================================
root_crontab:
  user: root
  jobs:
    - schedule: "0 3 * * *"
      command: /opt/scripts/backup-to-dropbox.sh
      purpose: Daily backup to Dropbox
      documented: false
      critical: true
      recommendation: "Document backup strategy"

    - schedule: "* * * * *"
      command: /opt/scripts/check-dropbox-mount.sh
      purpose: Verify Dropbox mount every minute
      documented: false
      critical: false
      recommendation: "Consider less frequent check (every 5 min)"

    - schedule: "0 4 1 * *"
      command: /opt/scripts/backup-infrastructure.sh
      purpose: Monthly infrastructure backup (1st of month at 4am)
      documented: false
      critical: true

    - schedule: "0 3 * * *"
      command: /opt/scripts/backup-wordpress-full.sh
      purpose: Daily WordPress full backup
      documented: false
      critical: true
      note: "Also in automation crontab - DUPLICATE?"

# =============================================================================
# AUTOMATION USER CRONTAB
# =============================================================================
automation_crontab:
  user: automation
  jobs:
    - schedule: "0 3 * * *"
      command: /opt/scripts/backup-wordpress-full.sh
      purpose: Daily WordPress full backup
      documented: false
      critical: true
      note: "Also in root crontab - DUPLICATE?"

    - schedule: "0 4 1 * *"
      command: /opt/scripts/backup-infrastructure.sh
      purpose: Monthly infrastructure backup
      documented: false
      critical: true

    - schedule: "0 5 * * 0"
      command: find /opt/backups -name "*.log" -mtime +30 -delete
      purpose: Weekly cleanup of old backup logs (Sundays at 5am)
      documented: false
      critical: false

    - schedule: "0 3 * * *"
      command: /home/automation/scripts/backup-media-stack-dropbox.sh
      purpose: Daily media stack backup to Dropbox
      documented: false
      critical: true
      note: "Also in root crontab - verify which runs"

# =============================================================================
# SYSTEM CRON (/etc/crontab)
# =============================================================================
system_crontab:
  location: /etc/crontab
  jobs:
    - schedule: "17 * * * *"
      user: root
      command: cd / && run-parts --report /etc/cron.hourly
      purpose: Run hourly cron jobs
      system: true

    - schedule: "25 6 * * *"
      user: root
      command: test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
      purpose: Run daily cron jobs
      system: true

    - schedule: "47 6 * * 7"
      user: root
      command: test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
      purpose: Run weekly cron jobs
      system: true

    - schedule: "52 6 1 * *"
      user: root
      command: test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
      purpose: Run monthly cron jobs
      system: true

# =============================================================================
# CRON.D DIRECTORY
# =============================================================================
cron_d:
  location: /etc/cron.d/
  files:
    - name: certbot
      purpose: SSL certificate renewal
      schedule: "0 */12 * * *"
      command: certbot -q renew
      documented: true

    - name: e2scrub_all
      purpose: ext4 filesystem scrub
      system: true

    - name: php
      purpose: PHP session cleanup
      system: true

    - name: popularity-contest
      purpose: Ubuntu package statistics
      system: true
      recommendation: "Can be disabled"

# =============================================================================
# ISSUES DETECTED
# =============================================================================
issues:
  duplicates:
    - job: backup-wordpress-full.sh
      locations: ["root crontab", "automation crontab"]
      recommendation: "CONSOLIDATE - keep only one"

    - job: backup-infrastructure.sh
      locations: ["root crontab", "automation crontab"]
      recommendation: "CONSOLIDATE - keep only one"

  high_frequency:
    - job: check-dropbox-mount.sh
      schedule: "every minute"
      recommendation: "Consider every 5 minutes to reduce load"

  undocumented:
    - backup-to-dropbox.sh
    - backup-infrastructure.sh
    - backup-wordpress-full.sh
    - backup-media-stack-dropbox.sh
    - check-dropbox-mount.sh

# =============================================================================
# BACKUP SCHEDULE OVERVIEW
# =============================================================================
backup_schedule:
  daily_3am:
    - backup-to-dropbox.sh (root)
    - backup-wordpress-full.sh (root & automation - DUPLICATE)
    - backup-media-stack-dropbox.sh (automation)

  monthly_1st:
    - backup-infrastructure.sh (root & automation - DUPLICATE)

  weekly_sunday:
    - Log cleanup (automation)

# =============================================================================
# RECOMMENDATIONS
# =============================================================================
recommendations:
  immediate:
    - "CONSOLIDATE duplicate cron jobs (backup-wordpress-full.sh, backup-infrastructure.sh)"
    - "DOCUMENT backup scripts and their purposes"

  short_term:
    - "REDUCE check-dropbox-mount.sh frequency to every 5 minutes"
    - "CREATE backup documentation page"
    - "ADD cron monitoring to Grafana"

  long_term:
    - "Consider migrating from cron to systemd timers for better logging"
    - "Add alerting for failed backup jobs"

# =============================================================================
# SUMMARY
# =============================================================================
summary:
  total_jobs: 12
  backup_jobs: 5
  maintenance_jobs: 3
  system_jobs: 4

  by_user:
    root: 4
    automation: 4
    system: 4

  issues:
    duplicate_jobs: 2
    undocumented: 5
    high_frequency: 1
