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

    Join Date
    Nov 2014
    Posts
    1
    Rep Power
    0

    New file existence in a directory


    I need a script to monitor a directory for incoming new files .
    If files are not received for last 1 hour or if the received file is empty in that 1 hour (there are chances that files received in that hour could be empty)then do so some something.

    What I tried


    Code:
    find . -cmin -60 -a -size 0

    No need to check the new files with existing files.All the incoming files are new file. I m completely new to unix

    OS:HP-UX
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Keeping in mind that cmin uses the inode change time and not a creation time,

    What you have there finds anything changed less than 60 minutes ago and is empty. I think what you're trying to get is "older than 60 minutes or empty"?
    Code:
    find . -cmin +60 -o -empty
    If you're going to delete those files, use -delete.

IMN logo majestic logo threadwatch logo seochat tools logo