I'm trying to write a script to run daily on a Ubuntu FTP server we have set up for customers to upload data to. The idea is that once a day, a script will run, check for new files uploaded by customers, and if there are any, email our help desk so they can go retrieve the files.
Here is what I've got so far:
#!/bin/sh
find /home -mmin -1440 -type f > /home/newuploads.txt
What this generates, is the following text file (newuploads.txt):
/home/fseportalmgrftp/users.txt
/home/fseportalmgrftp/.mailrc
/home/fseportalmgrftp/.msmtprc
/home/fseportalmgrftp/.bash_history
/home/check_for_new_files.sh
/home/dayold.sh
/home/newuploads.txt
How can I exclude these results? I only want files uploaded by customers. In this case, the users.txt file was uploaded by me, so i want just that to show, not stuff that's in there already, and not data that is generated (such as the newuploads.txt)
In addition to the above, I've got a script that emails the help desk as follows:
#!/bin/bash
sh /home/dayold.sh
if [ $(stat -c%s "newuploads.txt") -gt 0 ]
then
#send mail to help@savi.com if new files are uploaded
nail -A gmail -s "NEW files have been uploaded to the USMC FTP server" help@savi.com < /home/newuploads.txt
#remove file
rm -f /home/newuploads.txt
fi
Question
SirEvan
I'm trying to write a script to run daily on a Ubuntu FTP server we have set up for customers to upload data to. The idea is that once a day, a script will run, check for new files uploaded by customers, and if there are any, email our help desk so they can go retrieve the files.
Here is what I've got so far:
What this generates, is the following text file (newuploads.txt):
How can I exclude these results? I only want files uploaded by customers. In this case, the users.txt file was uploaded by me, so i want just that to show, not stuff that's in there already, and not data that is generated (such as the newuploads.txt)
In addition to the above, I've got a script that emails the help desk as follows:
Can someone help fix these the find script?
Thanks.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts