How to send a file in UNIX through email which is created only 15 minutes before the current time?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to send a file in UNIX through email which is created only 15 minutes before the current time?
# 1  
Old 01-12-2017
Linux How to send a file in UNIX through email which is created only 15 minutes before the current time?

I wanted to send an email to the client whenever there is failed record created in a /feed/HR-76/failed folder after processing of feed file.

I can find out with the help of below script that what is the new file created but that file didn't make just 15 minutes before.

Code:
LogDir=/feed/HR-76/failed
EMAIL1=xxx@gmail.com
SUBJECT=Failed
MESSAGE="Failed records"
SMTP="SMTPHOSTNAME"
SENDER=no-reply@gmail.com

inode=$(find /feed/HR-76/failed -maxdepth 1 -type f -iname '*.txt' -printf '%T@ %i\n' | sort -rn | awk '{print $2;exit;}')
newest=$(find /feed/HR-76/failed -maxdepth 1 -inum "$inode")
echo -e "$MESSAGE" | mailx -S smtp="$SMTP" -a "$OUT" -r "$newest" -s "$SUBJECT" "$EMAIL1"

Above code is giving me only file is on the top.

There is some time when there will be no failed record but this code is sending already existing file.

I want to send only failed record file which is created only 15 minutes before otherwise no file should send.The format of file is Employee_DD-MM-YYYY_HH-MM-SS.txt
# 2  
Old 01-12-2017
please post in adequate room
https://www.unix.com/how-to-post-in-t...-linux-forums/
Is for people with posting issues
thanks
Post moved
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

rsync a file as it gets created and after 3 minutes old

- run a backup job - The jobs creates partial files one after the other, about 2 minutes interval. What i want to do is that while the job is still running or while a file was last modified or created 3 minutes ago, the file should be rsync to a remote server untill the last file has been... (4 Replies)
Discussion started by: malaika
4 Replies

2. UNIX for Beginners Questions & Answers

Find if create time of last created file in a directory is older than 5 minutes

A process xyz is running and creating file1, file2, file3, .... filen. how do i know if the process has stopped and createtime of the last file (filen) is older than 5 minutes? OS is AIX (3 Replies)
Discussion started by: malaika
3 Replies

3. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

4. Shell Programming and Scripting

How to extract logs between the current time and the last 15 minutes ?

I want to extract the logs between the current time stamp and 15 minutes before and sent an email to the people configured. I developed the below script but it's not working properly; can someone help me?? I have a log file containing this pattern: Constructor QuartzJob ... (3 Replies)
Discussion started by: puneetkhullar
3 Replies

5. Shell Programming and Scripting

Check how many minutes ago the last file created

Hi , I need help in getting how many minutes ago the last file, matching some pattern in file name, was created in a folder. Thanks in advance. (8 Replies)
Discussion started by: Anupam_Halder
8 Replies

6. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

7. Shell Programming and Scripting

How to send email once a day at certain time in unix shell script

hi, i have to send an email once a day at ceratin time say 22. i have tried with date commad, but not working.:( HOUROFTHEDAY=`date +'%H'` if ; then mailx -s "Info" emailid@org.com < $ProcessStatisticsFile fi Please help me... (5 Replies)
Discussion started by: sreelu
5 Replies

8. Shell Programming and Scripting

How can i search a file which has been created or modified in last five minutes

Hi Can some one please help me How can i search a file which has been created or modified in last five minutes I have used the command find . -mmin -5 and it does not work i get an error -mmin is bad option Please help Much regards Tarun (2 Replies)
Discussion started by: tarundeepdhawan
2 Replies

9. UNIX for Advanced & Expert Users

Adding # minutes to current time...

Hi all, Looking for a way to add lets say 10 minutes to the current time output should look like 7:15 AM or 7:15 PM. I know that gdate could do this for me but unfortunately its not available on the system I'm working on. So if any one know any way I can accomplish this using the date command it... (7 Replies)
Discussion started by: gptavares
7 Replies

10. Shell Programming and Scripting

How can I create a file with current time - 60 minutes

I'm using k-shell in unix and I want to create a file with the current system time - 60 minutes. I know I can use touch to create the file, but I'm having trouble specifying how tell it to use the current time less 60 minutes. Any ideas??? (4 Replies)
Discussion started by: DaveyTN
4 Replies
Login or Register to Ask a Question