Finding file with tomorrow's date in name
I have a workflow where pdf files are going through a process and they could end up in an error folder. The files all have the day's date embedded in them. I would like to set up a cron job looking for files that have dropped in an error folder with tomorrow's date on them. Looking for today's date is trivial:
And I have a cron job that runs at 1:10am, 1:20am, 1:28am looking for files and it will send me an email. But most of the time the files have been in the Error directory for hours/days before -- how do I look for tomorrow-dated files the night before so that I can deal with them before I go to bed?
find . -name *_`date +%m%d`_*.pdf | grep "Error"
-- edited to add: I am running on mac os x version 10.6 I have perl installed (it's in the base install) but I don't seem to have gnuDate which would let me do the --date="1 day" thingy. Or I don't understand how to embed it in the command...
Last edited by cathyf; July 3rd, 2013 at 11:53 AM.
Reason: added OS info
In perl you can use the "time" functions to compute the next day.
Originally Posted by cathyf
Or, try this:
# Set to your Timezone: +
==> echo $(TZ=CST-24 date '+%Y%m%d')
July 11th, 2013, 09:53 AM
Found the answer, hope this helps somebody:
You can use a full complement of times, plus and minus for future and past, d for day, w for week, etc.
find . -name *_`date -v+1d +%m%d`_*.pdf | grep "Error"