1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Automatically delete files after X days?

Discussion in 'Synology' started by rstark18, Aug 12, 2017.

  1. rstark18

    rstark18 Occasional Visitor

    Joined:
    Oct 10, 2011
    Messages:
    42
    Is it possible to automatically delete files in a Shared Folder after a certain amount of days? I have a folder that gets security camera stills and video. I want that folder to delete any files older than X number of days. Can Task Scheduler be used with a script maybe? Can anyone think of a way to do this natively? I know I can use my PC backup program (SyncBack) to do it but would rather have it done on the NAS.
     
  2. Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!
  3. sfx2000

    sfx2000 Part of the Furniture

    Joined:
    Aug 11, 2011
    Messages:
    12,685
    Location:
    San Diego, CA
    study up on logrotate... does what you need...
     
  4. rstark18

    rstark18 Occasional Visitor

    Joined:
    Oct 10, 2011
    Messages:
    42
    I was hoping for a simpler way. I haven't found any examples of using logrotate to manage files other than log files.
     
  5. sfx2000

    sfx2000 Part of the Furniture

    Joined:
    Aug 11, 2011
    Messages:
    12,685
    Location:
    San Diego, CA
    One could do a crontab entry to sweep the files, but that'll wipe the entire directory.

    The other approach would be a shell script based on file system time stamps, and then write than into a crontab.

    Sorry - not really a simple way without doing some kind of shell scripting for automation.
     
  6. slidermike

    slidermike Occasional Visitor

    Joined:
    Sep 20, 2013
    Messages:
    47
Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!