Shell File Upload Monitor Script
Purpose of Script:
Clients will upload files on a daily basis to the server. When the file is finished uploading. The script will move the file to a different location and rename it, leaving the upload directory always empty.
Problem:
How do I use shell commands/operators to know when the file has finished uploading. Everytime i do a listing the file size will increment so i know i could do a script to do a dir listing every say 5-10 secs to continuosly monitor the file size. However do to a slow down in the internet, the transmission may be slow and not increment for sometime and then begin again. Is there a way to monitor this and when it's done move/rename the file?
This is the script so far.
ls -l ${SPATH}EigenA.????????.????.dat.compress | awk '{print $5}' > .listn1
echo "`date '+%D %T'` File Upload In Progress..." >> .sympalog
sleep 5
ls -l ${SPATH}EigenA.????????.????.dat.compress | awk '{print $5}' > .listn
while [ `cat .listn1` != `cat .listn` ]
do
sleep 3
ls -l ${SPATH}EigenA.????????.????.dat.compress | awk '{print $5}' > .listn1
echo "`date '+%D %T'` `cat .listn`" >> .sympalog
sleep 10
ls -l ${SPATH}EigenA.????????.????.dat.compress | awk '{print $5}' > .listn
echo "`date '+%D %T'` `cat .listn1`" >> .sympalog
done
********
All in all, is there another more professional/accurate way to go about this?
|