I do see a potential need for this sort of peg approach, especially if even a cron job misses or similar; or you'd need to just re-do the job. It would allow you to rely on a fixed timeframe, but methyl's point is well-taken since your point in the day would also need to be pegged to a difference between now and 6am.
A better approach would probably be to dummy up your timestamps and then use these within your find query string; I've always needed (and done) this in SQL, but I've never hunkered down to do it within the shell for files. I'm on Solaris, so GNU date is not an option, I'm using the standard issue ksh88 (on Solaris 10) or ksh93 (on Windows) and perl is not a viable option for the OP. So the question is really more over basic portability: can the shell manage a suitable date calculation method? And if it can, what's the most portable approach across the various shells?
Okay, so if you were able to pony up a reliable calculation of today's date-1 and date-2 (or better yet...any date-1 and date-2 args, to allow for any sort of catch-up situation...), you could effectively dummy up a timestamp and touch two files for use within the find command to use a query against -newer $date-1 and ! -newer $date-2. Since the available options will vary by your platform and/or shell, the components may vary, but the results shouldn't. Based on your original find command query's use of -mmin, it looks like you're either GNU or ksh93-based, so you might be able to use kshji's -d option, but this is more of a mental exercise for me. (I'd argue using perl is good for you, but there are many ways to get the required results.)
I'll take the wimp's way out for the moment and propose a pseudocode theory as opposed to actual code here, since I am crunched for time today, but the basic premise is as follows. (I'll provide actual code at some point, if I get a chance):
0) Calculate your timespan based on arguments to a function/script (ie, 2 and 1 to achieve two days ago and one day ago, etc);
-> this allows for flexibility in terms of days back, etc. (Can be expanded to apply to the specific timestamp as well...)
1) Take those calculated dates and dummy them up into a touch command such as follows:
-> note the use of literals in the timestamps, which allows for the inclusion of another variable-driven value;
2) Modify your find command to reflect these bookend files in your query:
I'd also recommend the following link with regard to going about actually calculating the days back value(s), since this would be specific to your platform and/or preferences (https://www.unix.com/answers-frequent...rithmetic.html)
Hi all,
I have been researching to obtain SSL certification expiry for most of our webistes. For some cases, some hosts where not directly accessible so i finally got a solution working with curl using my proxy. This lists the expiry date which i'm finally looking for.
# curl --proxy... (4 Replies)
Hi
I have shell script and I am facing the below issue to integrate the date calculation to the the script.
If I give the $1 as the date(20110701) then I need to get the 7 days ago date for the same format.(20110624).
At first I thought its a simple one to handle and I did a search in the... (10 Replies)
Hi,
the following gives today
$(date '+%d%m%y')
For example 210111 for today (21 of january 2011).
How can I have n days ego ? For example 160111 for 5 days ego ?
thank you. (3 Replies)
I know the topic of getting yesterday's date has been covered ad nauseum, but I just want to be clear on something.
I recently started using the command
date --date='1 days ago' '+%m/%d/%y'
to get yesterday's date and it's been working great. I just want to be certain that it is going to... (1 Reply)
Hi,
Anybody knows how to get what date was 28 days ago of the current system date through UNIX script.
Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago?
It has to be korn shell script.
Thanks. (2 Replies)
How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago?
It has to be korn shell script.
Thanks. (1 Reply)