Compare file timestamp with current date. Diff must be 1 hour.
Hello,
I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed.
The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of the first file, and then compare it with the second file. Once the difference is 50 minutes or more, then the files have to be compared based on their content and execute the lines that exist in both files.
I tried to use the "find -mmin" command, but find doesn't know the mmin parameter (HP-UX beryl B.11.11 U 9000/800).
I've found a lot of information on this forum already, so I hope someone can help me out! Thanks!
I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed.
The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of the first file, and then compare it with the second file. Once the difference is 50 minutes or more, then the files have to be compared based on their content and execute the lines that exist in both files.
I tried to use the "find -mmin" command, but find doesn't know the mmin parameter (HP-UX beryl B.11.11 U 9000/800).
I've found a lot of information on this forum already, so I hope someone can help me out! Thanks!
Why are you exporting these variables?
Quote:
There's no need for cat:
Quote:
Why are you calling rm 5 times?
Most of your script has nothing to do with the question you asked.
Last edited by DukeNuke2; 04-14-2010 at 11:05 AM..
Thanks for your reply. I know the script has some things in it which should be removed or changed, but I first would like to make it run fine. Once achieved, I will do a cleanup action. Thanks for the comments.
Also it was indeed not necessary to place the script within this post, but I thought it would be handy to help me out.
I think I can use your script very well, I`m going to test it right away!
So basically I have a log file and each line in this log file starts with a timestamp:
MON DD HH:MM:SS
SEP 15 07:30:01
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Dear All
I need to find out day diff between two dates. date -d or date -- day is not working in mine system.
Currently i am using below code but it gives me wrong value while month change.
IP:
Date 1: 20150802 11:30:45
Date 2: 20150728 16:30:45
code used:
awk '{t1=$2; t2=$4;... (7 Replies)
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Hello to all.
I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this:
Tue Mar 29 06:59:00... (5 Replies)
Hello - I have written the following basic shell script to count files, compare files and look for a particular strings in a file.
Problem 1: How do I define more than 1 file location?
#!/bin/bash
#this is a test script
FILES=$(ls /home/student/bin/dir1, home/student/bin/dir2)... (0 Replies)
I'm trying to compare 2 dates between current time and the timestamp on a file.
The date format is mmdd
Both return Apr 1 but when using if statement
line 11: Apr 1: command not found error is returned
#!/bin/sh
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /file.txt |... (1 Reply)
Normally we can use %s to find out the time in second since 1970.
But in my ksh, this format option is not available.
Example- date +%s
1268103151
above script command won't work in ksh. Can you guys provide its equivalent ? (3 Replies)
I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)