Take action only if a file is X hours (or seconds) old
shell: #!/bin/ash
I searched and found a few relevant posts (here and here - both by porter, on the same day (?)) however both are just a do while loop, I need to check a file date and compare it to the current time.
I would like it to say if file 'test' is more than 12 hours old than "right now" to echo back "file is stale" else echo "file is ok". I was thinking I could get the "unix time" of the file and just subtract them, but honestly I have no idea how to get the unix time of a file (much less in a script)
concept:
I'm sure there is a better/easier way to do this... Thanks all!
Have some files in /tmp/dir
abc.zip
123.zip
345.zip
and if name matches to 345.zip then take action
My code....
am i doing something wrong ? Please advise.
#!/bin/bash
set -x
cd /tmp/dir
for i in *.*
do
if ]
then (4 Replies)
Hi, please help with below time conversion to minutes.
one column values:
2 minutes 16 seconds 420 msec
43 seconds 750 msec
0 days 3 hours 29 minutes 58 seconds 480 msec
11 seconds 150 msec
I need output in minutes(total elapsed time in minutes) (2 Replies)
Hello All,
I am working on script where I need to add hours,minutes or seconds in the time.Time is not the current but it could be future time.I thought I can store that time in variable and add hours.minutes or second but I am not able to add that in the time that is stores in a variable.
Time... (9 Replies)
I have a problem. I am working on a Call Detail Report system. Come to find out the phone switch does not report in seconds. It is a 5 digit field that reports h:mm:ss
The problem is I have 1-5 digit numbers
Ie 1 = 1 second and should be reported as 0:00:01
22 should be 0:00:22
321 should be... (5 Replies)
I want the script to read the directory I am running the script from and print the contents of any file that has GX in it's title. This is the code needed. But how do I combine it?
#!/usr/bin/perl
opendir(CURRENT,".");
@list = readdir(CURRENT);
closedir(CURRENT);
foreach $item (@list){... (4 Replies)
This is my task - pls help
Write a script that will run every 5 min and check if a particular file has appeared in a particular directory. Once it appears then rename the file and move it a bkp directory and run another script. (3 Replies)
Hello,
I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe.
There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file.
cat test.sh... (2 Replies)
Hi experts,
I am reading two log files and passing dates as output to a txt file.
Code is given below:
echo "Start Time:" >> Report.txt
cat start.log | while read LINE1
do
echo $DATE1 >> Report.txt
done
echo "End Time:" >> Report.txt
cat end.log | while read LINE2
... (7 Replies)
What one finds challenging another finds simple...
(HPUX B.11.11)
I have a text file named something like 12345.dst that could look like this:
DOG
CAT
NONE
TEST
CAT
What I want to end up with is 12345.dst looking like this:
CAT
DOG
TEST
removing "NONE" should it be there and... (1 Reply)