#! /bin/bash

# Récupère le dossier contenant ce script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "$SCRIPT_DIR/vars"

log_dir=~/cronlogs/process_picking
mkdir -p "$log_dir"  # Crée le dossier s'il n'existe pas

MAXFILES=12960 # ~ 3 months every 5 minutes, 12 hours a day
curl -o ${log_dir}/reception_process_$(date +%F_%T).log http://$ip:$dj_port/reception/po_process_picking

ls -t ${log_dir}/*.log | sed 1,$MAXFILES\d | while read file ; do rm "$file"; done
