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.

updatedb causing high load every morning

Discussion in 'General Discussion' started by Metro2, Jul 12, 2006.

  1. Metro2

    Metro2 Well-Known Member

    Joined:
    May 24, 2006
    Messages:
    376
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Every morning around the same time I've been seeing a big jump in CPU / load, and it looks like updatedb is the culprit.

    I know it's important to have running so that locate works properly, but I'm wondering this - should it run every day? And are all of the options mine is running necessary? Here's what mine looks like when executing:

    /usr/bin/updatedb -f NFS,SMBFS,NCPFS,PROC,DEVPTS -e /tmp,/var/tmp,/usr/tmp,/afs,/net
     
  2. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    That is basically a file search cache for the locate command. If you do not need up to the second "locate" information for searches, then remove the updater from your cron or set it to run once a week or so...

    man updatedb to read more
     
  3. Metro2

    Metro2 Well-Known Member

    Joined:
    May 24, 2006
    Messages:
    376
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Thank for the input Jay, I have moved updatedb to it's own weekly run folder.

    Advanced/fluent users can ignore the rest of this post ;)

    For the benefit of any other users here who might be a bit novice at command line stuff like I am (I've always been heavily dependent on WHM and assistance from my data center), here is what I had to do to make this change and it might help you with other cron stuff in the future.

    First off, my /etc/crontab file looked like this:

    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly

    And my slocate.cron file (which runs updatedb) was located in /etc/cron.daily

    So my first inclination was to move slocate.cron to the /etc/cron.weekly folder, but I noticed that's where my makewhatis.cron is kept, so since I didn't want them both running at the same time I did this:

    mkdir /etc/cron.slocate (which made a new folder for the job)
    mv slocate.cron /etc/cron.slocate (which moved the job to the new folder)

    Then I edited my /etc/crontab file and added this extra line to it:
    22 5 * * 0 root run-parts /etc/cron.slocate

    So now the full contents of the /etc/crontab file look like this:

    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    22 5 * * 0 root run-parts /etc/cron.slocate
    42 4 1 * * root run-parts /etc/cron.monthly

    What that does is makes it so that the slocate (updatedb) cron runs an hour after the makewhatis cron on Sunday at 5:22am. There is a handy cron chart at this link which to help you understand what the 5 places of numbers and asterisks is for.

    Hopefully this info might help someone else who is still learning command line / cron related stuff.
     
  4. Metro2

    Metro2 Well-Known Member

    Joined:
    May 24, 2006
    Messages:
    376
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    PS - If anyone here thinks I went about it the wrong way, or if my terminology is wrong, or there is a better way, please feel free to respond and let us know.
     
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    What you've done isn't really the best way to do it. You should just move the cron shell script as you've done and then add it into the rootcrontab with:

    crontab -e

    And then add the line:

    22 5 * * 0 /etc/cron.slocate

    However, I don't really see the point in recreating the slocate database weekly as it renders it mostly useless. You may as well not bother running it at all.
     
  6. Metro2

    Metro2 Well-Known Member

    Joined:
    May 24, 2006
    Messages:
    376
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Thank you for the feedback Chirpy. If you get a chance sometime, could you maybe elaborate a little about why running updatedb weekly is useless, and whether or not you think it is important and if I should leave as daily?
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    The point of the locate command which uses the slocate database is to search for the location of files on your server. It can be aninvaluable tool in navigating the OS and installed applications and also for finding files uploaded by end-users. IF you only run it once a week, the file database is going to be very much out of date, containing files that no longer exist and files that have subsequently been created, and so reduces the use of the tool. Running it daily keeps the database up to date. If you don't use the locate command, or only use it for identifying files that rarely change, then you may as well not run the slocate cronjob and use the same database.
     
  8. Metro2

    Metro2 Well-Known Member

    Joined:
    May 24, 2006
    Messages:
    376
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Thanks a ton! And by the way, I've sent a couple of inquiries in at your helpdesk in regard to getting some more consulting, as you did a great job on my other server and I've recently leased a new one :D
     
  9. jeroman8

    jeroman8 Well-Known Member

    Joined:
    Mar 14, 2003
    Messages:
    410
    Likes Received:
    0
    Trophy Points:
    16
    If you are not so good with shell commands or doesn't like it you can use a sFTP program instead and control/access just as much.
    I use CuteFTP Pro and sFTP (ssh2) most of the time and you can browse the entire hard drive as root and edit any file with Cute FTP's text editor instead of using shell commands and editors like VI or Pico.
    So for editing, move, delete, upload files it is really good if you don't like the shell.
     
Loading...

Share This Page