fix: improve dockcheck cron job logging and reliability

- 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 <noreply@anthropic.com>
This commit is contained in:
2025-06-20 10:30:51 -06:00
parent 2cc05a19e6
commit 85cfca08f5
3 changed files with 34 additions and 2 deletions

View File

@ -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"