Setup OpenMediaVault to delete any files 60 days old automatically

  • I am wondering if there is a way to run command to automatically delete any files which are 60 days old or older and let say this command would be executed once a month or every 2nd month by the server...


    I have setup OpenMediaVault v.12 (Kralizec) and my DataDisk /dev/sdb1
    I setup in Shared Folder:
    CLPvideo
    Gaitlab
    Ghost


    I would like to have command that will delete any files which are 60 days or older from the CLPvideo folder


    I am not sure how I could do this in the OpenMediaVault. I there is a way could you please advice how I could do this?


    Thank you

  • Hello,


    First thoughts : I would write a shell script which does that and put it on a crontab (you can also use scheduled tasks in OMV)...


    You can use for example this command :


    Code
    find /media/yourstorage/CLPvideo -mtime +60 -type f -delete


    Becareful with the find command and the -delete option !!! make sure this is the good folder and the good path !!!

    - ASROCK FM2A88X-ITX+ (SATAIII (6Gb/s) x6 (for the DATA), mSATA x1 (for the OS))
    - AMD A6 7400K 3.5GHz
    - Corsair 2Go DDR3 1333MHz C9 (x2)
    - Intel Corporation 82574L Gigabit Network Connection
    - COOLER MASTER G450M (80+ bronze)
    - WD Red 2To 64Mo 3.5" SATAIII (6Gb/s)
    - 32 Go SSD mSATA KingSpec Half-Size Solid State
    - Fractal Design Node 304 black (HDD 3.5" x6)
    - RAID 5 XFS
    - OMV 4.1.35-1 Arrakis

  • Thank you for the link but also it shows to me to use Google search as well as how lazy I am to use a search engine???
    Sorry, probably I didn't provide enough information when I asked for the command about to move files. Believe it or not Mr. davidh2k I do use Google search on regular basis every day. I would like to thank you for people like you who willing share information and willing help other like me to understand Linux better, I feel novice in Linux, because of this Forum I am able to understand better, discover new possibilities and I am able to manage OpenMediaVault product. Thank you again!


    I found commands to move files but I am not sure which one is correct one for my need.
    I could test it to figure it out... but I thought to ask on this Forum first and I am hoping I will get answer.


    Here it is my extended question:


    Should I use this one? find /media/yourstorage/CLPvideo -mtime +60 -type f -mv '{}' /media/yourstorage/CLPvideo_old


    or should I use this one? find /media/yourstorage/CLPvideo -mtime +60 -type f -exec mv '{}' /media/yourstorage/CLPvideo_old


    I don't understand what -exec means? Even I did search for it but it is not clear to me...

  • exec executes the command you append to it for every file that the find command finds. ;)


    The use of xargs (you don't ask for that) may throw an error if there is no file found that fits your search terms. I haven't used '-mv' myself, so I can't answer what it does different thatn '-exec mv'


    Greetings
    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • I have tested today and it works for me great!


    this is the command I need for my needs: find /media/yourstorage/CLPvideo -mtime +60 -type f -exec mv '{}' /media/yourstorage/CLPvideo_old \;


    This shell command move any files which are 60 days old and older from /media/yourstorage/CLPvideo to /media/yourstorage/CLPvideo_old


    I thought to share with you.


    Thanks for your help

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!