Check if file got created in less than 10 hrs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check if file got created in less than 10 hrs
# 1  
Old 02-09-2015
Check if file got created in less than 10 hrs

Dear Gurus,

I want to check if file got created in less than 10 hrs in .ksh.
Here is my requirement

In $var5 : I'm storing file name
In $var4 I have stored : select to_char(sysdate,'YYYYMMDDHH:MM:SS') from dual;

If that file date time is less than 10 hrs, then I need to check
Code:
if [ -f /data1/proj/srcfile/$var5.txt$var4 ] less than 10 hrs
then
echo $var5$var4

Thanks,
Srinivas
# 2  
Old 02-09-2015
Do you insist on ksh (which would surprise me as your var4 is being filled from SQL, which certainly is an overkill at this point) ?

Two pointers into sort of solutions:
- Calculate your 10h back time from SQL as well; assign to another var.
- use the shell's builtin printf with the %(%s)T format specifier to get the actual system time (not sure if that works in ksh; it does in bash), subtract 36000 and use that for time comparisons.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check current date file is created and with >0 kb or not for multiple directories

Hi All, I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Check number of files that were created before a date?

Hi all, In a directory I have a lot of files created in history. However do I check the number of files that were created before a designated date? Thanks (1 Reply)
Discussion started by: isaacniu
1 Replies

4. Shell Programming and Scripting

check file exists and created today issue

Morning My other issue I have seems very simple but im just not seeing it. I have a script that checks on a remote share to see if the backups for some systems have run. Its as simple as: find /mnt/ukwcs-net-config/WLAN-Controllers/ -mtime -1 -ls | egrep '(cfg)' > wlanlog.txt cut -c 1-92... (4 Replies)
Discussion started by: ltodd2
4 Replies

5. Shell Programming and Scripting

Check file created is less than 4 hours or not.

Hi, I need to check some files in one directory whether any files has been created before 4 hours(ie, less than 4 hours from the current time). Can anybody help me out..? Thanks in advance..! (21 Replies)
Discussion started by: Kattoor
21 Replies

6. Shell Programming and Scripting

List last 10 Hrs file and find error files

Hi, I need a script that can search a word "Error" in last 10 Hrs generated logs in /log/App1 and /log/App2 folder.. Note these directories have massive log files ...actually our application generate 100 Log files of size 2MB in just a min so script must be fast enough to cater this I... (9 Replies)
Discussion started by: Mujtaba khan
9 Replies

7. UNIX for Dummies Questions & Answers

How to list files Created in last 2 hrs

I wanted to know what command should I use to see the files created in last 2 hours in a given directory. I know to see the files changed in last one day I can use this: find /admin//dump -type f -ctime -1 -print | xargs ls -lt|pg However I am not getting what should I use if I wanted tol... (4 Replies)
Discussion started by: rsonakiya
4 Replies

8. Shell Programming and Scripting

search for a file, if not found sleep and repeat it for 3 hrs

Hi, Can someone help me with this script .... I need a ksh script, which will search for a specific file in a directory, if file not found sleep for 10 mins and search again, if still not found sleep again for 10 mins and so on .... it should search for that file for 3 hours and if that file... (5 Replies)
Discussion started by: santosham
5 Replies

9. Shell Programming and Scripting

check for new file over 24 hrs

Hi all, I am trying to figure out a method to flag an error if a file has not arrived in a certain directory within 24 hrs of the last one arriving. I am currently writing the time to a file when a file is recieved. I then want to check for a new file reguarly but flag an error if it has been... (3 Replies)
Discussion started by: pxy2d1
3 Replies

10. Shell Programming and Scripting

To check the lists of file created between 30-60 min

Hi I have to write a script, that will find out the lists of files in a particular directory, which are created between 30-60 min intervals. (3 Replies)
Discussion started by: velocitnitin
3 Replies
Login or Register to Ask a Question