Téléverser les fichiers vers "SH"
This commit is contained in:
37
SH/Import_Donnees_Dossier_For_PBI.sh
Normal file
37
SH/Import_Donnees_Dossier_For_PBI.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
source /home/socleng-monoprix/exploit_batch/config-report-batch.properties
|
||||
#
|
||||
#Logs
|
||||
LOG_FILE="/home/socleng-monoprix/logs/Import_Donnes_Dossier_For_PBI.log"
|
||||
#
|
||||
# Date actuelle
|
||||
date_actuelle=$(date +%s)
|
||||
#
|
||||
# Calculer l'ann<6E>e il y a 5 ans
|
||||
annee_actuelle=$(date +%Y)
|
||||
annee_cible=$((annee_actuelle - 5))
|
||||
#
|
||||
# Date du 1er janvier il y a 5 ans
|
||||
date_cible=$(date -d "${annee_cible}-01-01" +%s 2>/dev/null || date -j -f "%Y-%m-%d" "${annee_cible}-01-01" +%s 2>/dev/null)
|
||||
#
|
||||
# Calculer la diff<66>rence en secondes
|
||||
diff_secondes=$((date_actuelle - date_cible))
|
||||
#
|
||||
# Convertir en jours
|
||||
nb_jours=$((diff_secondes / 86400))
|
||||
echo "=== debut" >> "$LOG_FILE"
|
||||
echo "=== $(date '+%Y-%m-%d %H:%M:%S') ===" >> "$LOG_FILE"
|
||||
echo "Nombre de jours entre le 1er janvier d'y il ya 5 ans et aujourd'hui : $nb_jours" >> "$LOG_FILE"
|
||||
#
|
||||
# Suppression des donnees de la table f_dossier_v2
|
||||
# echo "lancement truncate table f_dossier_v2" >> "$LOG_FILE"
|
||||
# echo "=== $(date '+%Y-%m-%d %H:%M:%S') ===" >> "$LOG_FILE"
|
||||
# psql -U $user -h $hote -d $base -c "TRUNCATE TABLE report.f_dossier_v2 CONTINUE IDENTITY RESTRICT;" >> "$LOG_FILE" 2>&1
|
||||
#
|
||||
# Import des donnees de la table f_dossier_v2
|
||||
echo "lancement import des donnes table f_dossier_v2" >> "$LOG_FILE"
|
||||
echo "select report.refresh_dossier($nb_jours);" >> "$LOG_FILE"
|
||||
psql -U $user -h $hote -d $base -c "select report.refresh_dossier($nb_jours);" >> "$LOG_FILE" 2>&1
|
||||
echo "=== $(date '+%Y-%m-%d %H:%M:%S') ===" >> "$LOG_FILE"
|
||||
echo "=== fin" >> "$LOG_FILE"
|
||||
Reference in New Issue
Block a user