Find the answer to your Linux question:
Results 1 to 3 of 3
Hey- so we have this fax server that is running a linux kernel and not an actual dist. from what I understand. Here is my problem: I need to be ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    2

    Need a little help with some find and delete


    Hey- so we have this fax server that is running a linux kernel and not an actual dist. from what I understand. Here is my problem:

    I need to be able to script something to log into the box, run a find similar to the following:
    find . -type d -name "0*" -mtime +5 |wc -l

    this will list the files that are more than 5 days old? Is this right? If so, great. Now I would like to delete them:

    being the newb I am, I figured I would try this one:

    rm -rf `find . -type d -name "0*" -mtime +5

    ?
    I have leanrted how to find and delete using:
    ls -l |grep "^d.*Sep 13" |xargs rm -rf to delete every file from Sep 13. Works ok I guess.

    What I want to really do is set this up in chrontab to delete the specific files that are older than 5 days and run this script every 5 days.

    There is also something called busybox that is also giving me problems- no idea what that is.

    # rm -rf find . -type d -name "0*" -mtime +5
    rm: invalid option -- t
    BusyBox v1.00 (2010.06.21-20:43+0000) multi-call binary

    Usage: rm [OPTION]... FILE...

    # rm -rf `find . -type d -name "0*" -mtime +5
    >
    but I get the > prompt. What does this mean? how do I deal with it?


    If anyone can just help me that we would be great!


    thanks
    b

  2. #2
    Just Joined! barriehie's Avatar
    Join Date
    Apr 2008
    Location
    The Desert!
    Posts
    85
    Quote Originally Posted by bsoth View Post
    Hey- so we have this fax server that is running a linux kernel and not an actual dist. from what I understand. Here is my problem:

    I need to be able to script something to log into the box, run a find similar to the following:
    find . -type d -name "0*" -mtime +5 |wc -l

    this will list the files that are more than 5 days old? Is this right? If so, great. Now I would like to delete them:

    being the newb I am, I figured I would try this one:

    rm -rf `find . -type d -name "0*" -mtime +5

    ?
    I have leanrted how to find and delete using:
    ls -l |grep "^d.*Sep 13" |xargs rm -rf to delete every file from Sep 13. Works ok I guess.

    What I want to really do is set this up in chrontab to delete the specific files that are older than 5 days and run this script every 5 days.

    There is also something called busybox that is also giving me problems- no idea what that is.

    # rm -rf find . -type d -name "0*" -mtime +5
    rm: invalid option -- t
    BusyBox v1.00 (2010.06.21-20:43+0000) multi-call binary

    Usage: rm [OPTION]... FILE...

    # rm -rf `find . -type d -name "0*" -mtime +5
    >
    but I get the > prompt. What does this mean? how do I deal with it?


    If anyone can just help me that we would be great!


    thanks
    b
    You're getting the > prompt because you forgot to close the beginning ' in your CLI. Can also run find with the -exec option to find and delete at the same time.
    Code:
    find . -type d -name 0* -mtime +5 -exec rm -rf {} \;
    or alternatively
    Code:
    find . -type d -name 0* -mtime +5 | xargs rm -rf

  3. #3
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,244
    Quote Originally Posted by bsoth View Post
    There is also something called busybox that is also giving me problems- no idea what that is.

    # rm -rf find . -type d -name "0*" -mtime +5
    rm: invalid option -- t
    BusyBox v1.00 (2010.06.21-20:43+0000) multi-call binary

    Usage: rm [OPTION]... FILE...
    BusyBox is a single program that emulates all the basic Linux commands and utilities; it's just a way of fitting a working Linux shell into a tiny space. When you type "rm" on a system that has BusyBox installed, instead of the rm program running, BusyBox runs - and similarly for all the other commands. Therefore, if you enter erroneous syntax, the error message comes from BusyBox.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  4. $spacer_open
    $spacer_close

Posting Permissions

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