I'm trying to make a bash file (.sh) then when a file gets transferred it executes. This is the code:
#!/bin/sh
cd /files/usrdev/upload/datalake/GB/SQL/
FILE=CTL_MGB_????????.txt
INSTANCE=pevm-etlm001
PROJECT=pe-datalake01-dev
ZONE=us-east1-b
if [ -s "$FILE" ]; then
gcloud compute instances start "$INSTANCE" --zone="$ZONE" --project="$PROJECT"
fi
When the file CTL_MGB_????????.txt (the ???????? is a date YYYYMMDD with this format). I'm trying to use this sentence: if [ -s "$FILE" ]; then checks if the file exists and if it does it should start a compute engine in google cloud. When I executed it works, but I don't know how to make it automatically.