So I did a bash script that read a file in which are directory numbers and then proceeds to run pgloader over them.
I looks like this
#create logs for pgloader
Date=`date +%Y_%m_%d`
LOGS="pgloader_logs_$Date"
touch "$LOGS"
echo "loading files from dat folder"
echo "--------------------------------"
pgloader dat/*.load 2> "$LOGS"
#Read brand numbers from input file
while IFS='' read -r line || [[ -n "$line" ]]; do
#check if dlnr is valid
dlnr=$line
if [[ $dlnr == ???? ]]; then
echo "loading files from $dlnr folder"
echo "--------------------------------"
pgloader $dlnr/*.load 2>> "$LOGS"
fi
done < "$1"
exit 1
The directory where i run it looks like
0002 0005 0021 ... setUpDB.sh brandsnr
I run it using echo "./setUpDB.sh brandsnr >> someFileToGetTheOutput" | at TIME
The problem is it never runs inside the while for some reason. Is the at command not able to read files ? Because I tried to use a for loop with a number increment instead of reading from the file but it doesn't run inside it either...
The script works perfectly when I run it myself. I just need to be able to launch it overnight...
atruns the script? Since you're not redirecting stderr, you'll probably find this in your mailbox.>>only redirectsstdout. I don't have mail since it is root that runs it. I just relaunched it withat nowand I get this error./setUpDB.sh: 52: ./setUpDB.sh: [[: not found[[builtin is a bashism. Try adding the shebang line#!/bin/bashto the top of your script to make it explicit.