How to check xml file through out the day

Hi,

I have a file with extension xml. So i need to search for this file and sftp.

This script has to run from 8.00am to 8.00pm and during this when ever a file with *.xml exists in a particular directory , it has to sftp that file.

How can i make script check for this file through out the day ?

Kindly help.

if [ $(date +%H) -ge 8 -o $(date +%H) -le 20 ]
then
        ls -ltr *.xml > /dev/null
        if [ $? -eq 0 ] ; then
                <<sftp-code>>
        else
                echo "Files not present"
        fi
fi

Also make a entry into crontab to run the below script on regular interval like this :

  • 8-20 * * * <script file with path> :slight_smile:
    hope this will solve ur query.