From 85cfca08f5e8d27081c97f0f16516809491c8d24 Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 20 Jun 2025 10:30:51 -0600 Subject: [PATCH] fix: improve dockcheck cron job logging and reliability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added comprehensive logging to /var/log/dockcheck/dockcheck.log - Created wrapper script to avoid cron variable escaping issues - Added timestamp logging for each execution with exit codes - Created proper log directory with correct permissions - Removed unnecessary -n flag (config file handles DontUpdate=true) - Added cron handlers for service management 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 1 + roles/cron/handlers/main.yml | 6 ++++++ roles/cron/tasks/main.yml | 29 +++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 roles/cron/handlers/main.yml diff --git a/CLAUDE.md b/CLAUDE.md index bccdabe..109bc7c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -135,6 +135,7 @@ Common domains requiring hairpinning fixes: - karakeep (formerly called hoarder) is deployed with both 'hoarder' and 'karakeep' tags for backward compatibility - whenever i ask you what containers need updates, run dockcheck and return a list of containers needing updates - when i ask for the status container updates i want you to run dockcheck on the docker host https://github.com/mag37/dockcheck?ref=selfh.st +- this is your reference for glance configuration https://github.com/glanceapp/glance/blob/main/docs/configuration.md#configuring-glance ## Variable Management Implementation Notes **Major Infrastructure Update**: Variable management system was implemented to replace all hardcoded values with centralized variables. diff --git a/roles/cron/handlers/main.yml b/roles/cron/handlers/main.yml new file mode 100644 index 0000000..ca1b222 --- /dev/null +++ b/roles/cron/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# Handler to restart systemd-journald service +- name: restart rsyslog + systemd: + name: systemd-journald + state: restarted \ No newline at end of file diff --git a/roles/cron/tasks/main.yml b/roles/cron/tasks/main.yml index 47c2227..da8c960 100644 --- a/roles/cron/tasks/main.yml +++ b/roles/cron/tasks/main.yml @@ -1,4 +1,7 @@ --- +# Enable cron logging in systemd-journald (already enabled by default) +# We'll rely on journalctl for cron execution logs + # Ensure the script is copied to the target machine - name: Copy the warhammer feed update script copy: @@ -80,11 +83,33 @@ owner: phil group: phil -# Create cron job for dockcheck as phil user +# Create log directory for dockcheck +- name: Create dockcheck log directory + file: + path: /var/log/dockcheck + state: directory + mode: '0755' + owner: phil + group: phil + +# Create dockcheck wrapper script to avoid cron escaping issues +- name: Create dockcheck wrapper script + copy: + dest: /home/phil/.local/bin/run_dockcheck.sh + mode: '0755' + owner: phil + group: phil + content: | + #!/bin/bash + cd /home/phil + /home/phil/.local/bin/dockcheck.sh >> /var/log/dockcheck/dockcheck.log 2>&1 + echo "$(date "+%Y-%m-%d %H:%M:%S") - Dockcheck completed with exit code $?" >> /var/log/dockcheck/dockcheck.log + +# Create cron job for dockcheck as phil user with logging - name: Create cron job for dockcheck container updates cron: name: "Check Docker container updates" minute: "0" hour: "8" user: phil - job: "/home/phil/.local/bin/dockcheck.sh" + job: "/home/phil/.local/bin/run_dockcheck.sh"