The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need help with setting up a cron job

Discussion in 'General Discussion' started by positive, Dec 27, 2004.

  1. positive

    positive Member

    Joined:
    Mar 29, 2003
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I need a cron job that removes files larger than 50mb under the /tmp directory (checking every 10 minutes)


    anyone can help?


    Happy holidays.
     
  2. sleddog

    sleddog Active Member

    Joined:
    Jun 13, 2004
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Labrador, Canada
    You will probably need a script -- in perl or another language that you're familiar with. Basically it would do something like this:

    1. Capture the output of ls -l.
    2. Split that into lines.
    3. Split each line into items - filename, filesize, owner, etc.
    4. For each line, evaluate the filesize item to see if it is greater than the specified limit;
    5. If yes, push the filename onto a new array.
    6. Process the new array, deleting each file it contains.

    But perhaps someone else has ideas....
     
Loading...

Share This Page