sql files
This commit is contained in:
50
scripts/check_duplicate_file.sh
Executable file
50
scripts/check_duplicate_file.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
HOME="/home/compegence/customer"
|
||||
#Directories
|
||||
homeDir=$HOME/MMT
|
||||
configDir=$homeDir/conf
|
||||
input_file=$configDir/etl-config.txt
|
||||
declare -A credentials
|
||||
while IFS="=" read -r key value; do
|
||||
credentials[$key]=$value
|
||||
done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file )
|
||||
#for i in ${credentials[@]}; do echo ***$i; done
|
||||
|
||||
user=${credentials[user]}
|
||||
password=${credentials[password]}
|
||||
host=${credentials[host]}
|
||||
db=${credentials[db]}
|
||||
protocol=${credentials[protocol]}
|
||||
server=${credentials[server]}
|
||||
|
||||
postgres_con="psql -A -t postgresql://$user:$password@$host/$db"
|
||||
|
||||
count=`$postgres_con -c "select count(*) from fw_core.fw_jobctl_file_runschedule"`
|
||||
if [[ $count -eq 0 ]]
|
||||
then
|
||||
$postgres_con -q -c "update fw_core.fw_jobctl_runschedule_jobstep set end_status_note ='no_duplicate_file_found', end_status='success',end_time = now() where job_script_type = 'shell_script' and job_id = 1 and step_id= 1 and latest_runschedule_flag='1'"
|
||||
else
|
||||
while IFS= read -a filenames
|
||||
do
|
||||
file_name=$(echo $filenames | sed 's/[[:space:]]/\\ /g')
|
||||
if [ $(echo "-f $homeDir/files/landing/$file_name") ];
|
||||
then
|
||||
echo "File: $file_name is already processed and is moved to Duplicate Folder"
|
||||
move=$(echo "mv $homeDir/files/landing/$file_name $homeDir/files/duplicate_file/$file_name")
|
||||
eval $move
|
||||
|
||||
#update ctl table to exit for duplicate files
|
||||
$postgres_con -q -c "update fw_core.fw_jobctl_runschedule_jobstep set end_status_note ='duplicate_file_found', end_status='success',end_time = now() where job_script_type = 'shell_script' and job_id = 1 and step_id= 1 and latest_runschedule_flag='1'"
|
||||
else
|
||||
$postgres_con -q -c "update fw_core.fw_jobctl_runschedule_jobstep set end_status_note = 'no_duplicate_file_found', end_status='success',end_time = now() where job_script_type = 'shell_script' and job_id = 1 and step_id= 1 and latest_runschedule_flag='1'"
|
||||
fi
|
||||
done < <($postgres_con -c "select file_name from fw_core.fw_jobctl_file_runschedule where end_status_note='TRX_completed' and end_status ='success'")
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#$postgres_con -c "insert into fw_core.track_jobstep select *,'duplicate_check' from fw_core.fw_jobctl_runschedule_jobstep;"
|
||||
#$postgres_con -c "insert into fw_core.track_file select *,'duplicate_check' from fw_core.fw_jobctl_file_runschedule;"
|
||||
#$postgres_con -c "insert into fw_core.track_file_sheet select *,'duplicate_check' from fw_core.fw_jobctl_file_sheet_runschedule;"
|
||||
|
||||
Reference in New Issue
Block a user