#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    11

    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:

    Code:
    find . -name *_`date +%m%d`_*.pdf | grep "Error"
    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?

    -- 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 12:53 PM. Reason: added OS info
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    859
    Rep Power
    388

    Cool


    Originally Posted by cathyf
    . . . 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:
    . . . E t c . . .
    -- 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...
    In perl you can use the "time" functions to compute the next day.

    Or, try this:
    Code:
    # Set to your Timezone: +
    #              v--------+
    ==> echo $(TZ=CST-24 date '+%Y%m%d')
    20130706
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    11
    Found the answer, hope this helps somebody:

    Code:
    find . -name *_`date -v+1d +%m%d`_*.pdf | grep "Error"
    You can use a full complement of times, plus and minus for future and past, d for day, w for week, etc.

IMN logo majestic logo threadwatch logo seochat tools logo