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.

/tmp clear?

Discussion in 'Security' started by ozzieonline, Dec 24, 2012.

  1. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Wow... and all of a sudden the /tmp directory from my cPanel account is filled with a few MB's of statistics data. I don't want that to happen! I don't want to lose diskspace. Is there a way to prevent this? Should I disable the statistics programs or is there another way? Maybe run a cronjob that clears the directory (if so, can someone explain how since I've never done this before)..

    Many thanks for your replies.
     
  2. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    crontab simple-minded line to expire files in /tmp that are older than 90 days:
    0 * * * * find tmp -mtime +90 -print0 | xargs -0 rm -f 2>/dev/null
     
  3. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Can someone give me some information about a program called tmpwatch? I read some people use this to clean their temp files.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    That's not for clearing the tmp directory on a cPanel account.

    More Info? Open your browser to google and type this in:
    site:forums.cpanel.net tmpwatch

    Lots of reading there to get you going in the right direction.

    Statistics can be helpful for many things. If you don't want them, turn them off.
     
  5. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Allright thannks. Will deep digger in to this.
     
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    It's really the best way to go. Most questions that a 'new to all of this user' might have, have been asked many times over. Instead of reinventing the wheel, take the design of how things are done, mapped out by others already, and make it better on your own terms.


    Good luck!
     
  7. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Yes, I sort of agree... but I'm learning and travel my way through this. I'm new on everything and asking more experienced people for advice is the best way to learn new things. A forum is an excellent medium for this purpose. I'm quite experienced in PHP and am helping other people with their questions as well (on antoher forum). I hope people are kind enough to help me out with my questions. Whenever you start something new, you need to learn and this takes time. For you the answers to all of my questions might seem obvious, but remember your first time configuring a server, or learning how to drive a car? You were glad with all the help you could get trying to realise the first steps. Try to see my questions in the same light. In time I will know my way around, but there's a first time for everything.
     
  8. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    If you are referring to the tmp directory in a cPanel account ($HOME/$USER/tmp), then if you delete the data there, you destroy the data produced by your stats programs. Analog, Awstats and Webalizer all store their reports there, and you should not delete data indiscriminately.

    If you do delete those data, there is no way to get them back, if you have domains' logs set to be deleted after each stats run. That is the default setting, in Home » Server Configuration » Tweak Settings.

    Deleting data in an account's tmp directory will definitely cause Awstats, Analog and Webalizer to stop showing data. Logaholic and bandwidth data are stored there as well. A cron job to delete all data in a tmp directory is generally a bad idea.
     
  9. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Oké, thansk for the clarification.

    However... how do I avoid that the tmp directory in a cPanel account gets too big? It's small now, but I don't want it too grow hundreds of MB's. Can I somehow limit the folder size? Or is there another way to stop this directory from getting too big?
     
  10. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,471
    Likes Received:
    199
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    It will take years to grow to "hundreds of MB's"

    If you don't want or need them, turn them off.

    Home » Server Configuration » Statistics Software Configuration
     
  11. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    I did not say that I don't want them, did I???

    I was asking how I could control / restrict the folder size.
     
  12. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    621
    Likes Received:
    6
    Trophy Points:
    18
    As Jared said, deleting whole /tmp is not good idea. Im using this cron twice a day. It might be stupid, but you may get an idea:

    rm -rf /home/yourusername/mail/new/*;rm -rf /home/yourusername/public_html/error_log;rm -rf /home/yourusername/public_html/*/error_log;rm -rf /home/yourusername/public_html/*/*/error_log;rm -rf /home/yourusername/tmp/analog;rm -rf /home/yourusername/tmp/awstats;rm -rf /home/yourusername/tmp/webalizer;rm -rf /home/yourusername/tmp/webalizerftp;

    What does it do?
    It deletes system emails which stays in /mail/new
    It deletes error_log files 2 levels deep from /public_html/
    It deletes webalizer, webalizerftp, awstats, analog stats
     
  13. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Running that cron job twice a day is really a bad idea.

    The problem with this is that it is going to delete stats data, and also deleting error logs is going to make it very difficult to troubleshoot problems that happen on sites. You can set the default address to fail unrouted mail, instead of delivering it to the mailbox, effectively ending the need to empty the default mailbox. It is your decision, of course, to do whatever you want on your server, but mass deletion of even selected files is likely going to cause complaints from your customers.
     
Loading...

Share This Page