Lab 12.3 - Automatisation Complète
Objectifs
- Créer un système d'automatisation complet
- Intégrer cron avec scripts
- Gérer les erreurs
- Notifications
Exercice 1: Framework d'Automatisation
# Structure
mkdir -p ~/automation/{scripts,logs}
# Script principal
cat > ~/automation/automation.sh << 'EOF'
#!/bin/bash
set -euo pipefail
LOG_DIR="$HOME/automation/logs"
LOG="$LOG_DIR/automation-$(date +%Y%m%d).log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG"
}
log "Début automatisation"
# Tâches...
log "Fin automatisation"
EOF
chmod +x ~/automation/automation.sh
Exercice 2: Crontab
# Ajouter au crontab
crontab -e
# */5 * * * * $HOME/automation/automation.sh
Lab créé le: Décembre 2024 - Testé sur Ubuntu 24.04