Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Script to clean recycle bins

  1. #11
    Join Date
    Nov 2011
    Beans
    12

    Re: Script to clean recycle bins

    Yes there is


    Code:
    [/share] # cd HDA_DATA
    [/share/HDA_DATA] # ls
    Documents/           Network Recycle Bin/ Usb/                 charlie.mccormack/   pictures/            tempdownload/
    Download/            Public/              Web/                 lost+found/          sheri.mccormack/     torrentdownload/
    Multimedia/          Recordings/          aquota.user          music/               sydney.mccormack/    video/
    [/share/HDA_DATA] # cd Network*
    [/share/HDA_DATA/Network Recycle Bin] #

    Quote Originally Posted by dannyboy79 View Post
    is there a folder at that location? lol

    Network Recycle Bin is not a folder that Ubuntu creates I know that much

  2. #12
    Join Date
    Nov 2011
    Beans
    12

    Re: Script to clean recycle bins

    Ok it did something, but my network recycle bin did not shrink in size. Its still 100 GB with stuff about 1 year old in it. My goal once again is delete all files that more than 90 days old.


    Code:
    rm: /share/HDA_DATA/Network Recycle Bin/video/DVD_VIDEO_RECORDER: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/video/DVD_VIDEO_RECORDER/VIDEO_TS: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web/wordpress: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web/wordpress/wp-content: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web/wordpress/wp-content/uploads: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web/wordpress/wp-content/uploads/2012: is a directory
    rm: /share/HDA_DATA/Network Recycle Bin/Web/wordpress/wp-content/uploads/2012/10: is a directory
    [/share/Data/templates]

  3. #13
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    7,133

    Re: Script to clean recycle bins

    Quote Originally Posted by mackconsult View Post
    I have a qnap TS259 that runs ubuntu. I am trying to create a script that would clean up the recycle bin's for everything older than 3 months, by default the web GUI of the administration page does it every 12 months.

    here is the script I have currently:

    Code:
    #!/bin/sh
    ####################################
    #
    # simple script that will walk thru the
    # recycle bins on NAS and delete everything
    # older than 90 days
    #
    ####################################
    
    /usr/bin/find /share/HDA_DATA/"Network Recycle Bin"/*.* -mtime +90 -rm {} \;
    Going back to the original script:

    I think it is quite close: just change *.* to *
    The wild card * should not be within quotes

    Code:
    /usr/bin/find /share/HDA_DATA/"Network Recycle Bin"/* -mtime +90 -delete
    or
    Code:
    /usr/bin/find /share/HDA_DATA/"Network Recycle Bin"/* -mtime +90 -exec echo rm {} \;
    The use of -exec has the advantage, that you can test it with an echo inserted before doing the real thing: think -exec echo ... and check before
    Code:
    /usr/bin/find /share/HDA_DATA/"Network Recycle Bin"/* -mtime +90 -exec rm {} \;
    I use a similar alias to identify what was touched during the last seven days in the current directory

    Code:
    alias lastweek='sudo find * -ctime -7 -type f'

  4. #14
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,243
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Script to clean recycle bins

    Going back to the original script:
    find used in that system is crippled and half the options from gnu find don't work, as evidenced by the very short list of allowed options printed.

    Ok it did something, but my network recycle bin did not shrink in size. Its still 100 GB with stuff about 1 year old in it. My goal once again is delete all files that more than 90 days old.
    Code:
    rm: /share/HDA_DATA/Network Recycle Bin/video/DVD_VIDEO_RECORDER: is a directory
    rm can't remove directories by default, try adding -rf option (recursive, force). Be careful, rm -rf is serious business, one space in wrong place and you can wipe out everything.
    you need to investigate by hand if the files that fit the criteria survive, temporarily use echo "$f" instead of rm -rf "$f" to get the printout and check the items.
    Last edited by Vaphell; January 4th, 2013 at 08:27 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #15
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    7,133

    Re: Script to clean recycle bins

    Quote Originally Posted by Vaphell View Post
    find used in that system is crippled and half the options from gnu find don't work, as evidenced by the very short list of allowed options printed.

    rm can't remove directories by default, try adding -rf option (recursive, force)
    you need to investigate by if the files that fit the criteria survive, temporarily use echo "$f" instead of "rm -rf "$f" to get the printout and check the items.
    I see. So it is not 'vanilla' Ubuntu or Ubuntu Server. Would it be possible to install 'our standard find'? If not, why?

  6. #16
    Join Date
    Jun 2008
    Location
    Tennessee
    Beans
    3,413

    Re: Script to clean recycle bins

    Quote Originally Posted by Vaphell View Post
    rm can't remove directories by default, try adding -rf option (recursive, force). Be careful, rm -rf is serious business, one space in wrong place and you can wipe out everything.
    you need to investigate by hand if the files that fit the criteria survive, temporarily use echo "$f" instead of rm -rf "$f" to get the printout and check the items.
    It'd probably safer to run two find commands: the first one specifying "-type f" and running rm, the second specifying "-type d" and running rmdir.

    Since rmdir won't remove non-empty directories, you won't be deleting (for example) a folder more than 90 days old containing files that are less than 90 days old. "rm -Rf" would do this.

  7. #17
    Join Date
    Jun 2008
    Location
    Tennessee
    Beans
    3,413

    Re: Script to clean recycle bins

    Quote Originally Posted by sudodus View Post
    I see. So it is not 'vanilla' Ubuntu or Ubuntu Server. Would it be possible to install 'our standard find'? If not, why?
    The only reason would be space. Busybox is a shell with "reasonable facsimiles" of common shell tools baked into it, all in a very tiny package.

    If you want the real "find", I assume you'd have to install a real shell like bash or dash, and then the "findutils" package.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •