SFTP monitor/ File monitoring

What we are looking 

W need to monitor a file on destination directory

DESTDIR="Path"

DESTFILE="File name"

Currently what is set up 

 Bash script that automates the process of retrieving a file named "SEG" from a remote server using SFTP and then copying it to two other servers. It also sends an email notification with the status of the file transfer. Here's a summary of what the script does:

  1. Sets the values of several variables (USER, SOURCEHOST, SOURCEPORT, SOURCEDIR, SOURCEFILE, DESTDIR, DESTFILE, QASERVER, DRSERVER, and EMAIL) that are used throughout the script.
  2. Creates a directory named "local directory" if it doesn't already exist.
  3. Initiates an SFTP connection to the remote server (SOURCEHOST) using the specified port number (SOURCEPORT) and username (USER). It changes to the specified directory (SOURCEDIR), lists the files in that directory, and retrieves the file named "URSAV" to the local directory "local directory".
  4. If the SFTP connection fails, it sends an email notification to the specified email address (EMAIL) with a message indicating the problem and exits the script with an error code (1).
  5. If the file "SEG" was successfully retrieved, it creates a backup of the file with a timestamp in the filename and moves the original file to the specified destination directory (DESTDIR). It then uses rsync to copy the file to two other servers (QASERVER and DRSERVER).
  6. Sends an email notification to the specified email address (EMAIL) with a message indicating the success of the file transfer.
Parents Reply Children
No Data