Skip to content

Instantly share code, notes, and snippets.

@u1and0
Last active June 14, 2019 04:15
Show Gist options
  • Select an option

  • Save u1and0/fe24525516fce2017ae51c1fb3ef2928 to your computer and use it in GitHub Desktop.

Select an option

Save u1and0/fe24525516fce2017ae51c1fb3ef2928 to your computer and use it in GitHub Desktop.
updatedbとlocateの応用
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/root
# Heart beat
* * * * * echo `date` >> /var/log/cron.log
# cron backup
0 12 * * * crontab -l > /home/vagrant/BACKUP/crontab.txt
# updatedb commands
# docker system
0 12 * * * time updatedb >> /var/log/cron.log 2>&1
# C drive home
1 12 * * * time updatedb -U '/home/vagrant' --output='/var/lib/mlocate/mlocatelocal.db' >> /var/log/cron.log 2>&1
# Share Common
4 12 * * * time updatedb -U '/ShareUsers/UserTokki/Common' --output='/var/lib/mlocate/mlocatecommon.db' >> /var/log/cron.log 2>&1
# Share Personal
12 12 * * * time updatedb -U '/ShareUsers/UserTokki/Personal' --output='/var/lib/mlocate/mlocatepersonal.db' >> /var/log/cron.log 2>&1
$ updatedb -U '/home/vagrant' --output='/var/lib/mlocate/mlocateilocal.db'

200G /home/vagrant の領域で37秒かかった wc -l コマンドで調べると129266ファイル データベースファイルは2.8MB

-Uでデフォルト以外のインデックス領域を指定し、--outputで出力先データベース名を入力する

$ updatedb -U '/ShareUsers/UserTokki/Common' --output='/var/lib/mlocate/mlocateishare.db'

du -hd1で調べると1.1TB データベース化に7分45秒かかった データベースファイルは52MB

$ updatedb -U '/ShareUsers/UserTokki/Personal' --output='/var/lib/mlocate/mlocatepersonal.db'
データベース化100MB 19分06秒かかった
`wc -l` で調べたファイル数449821
$ locate --databese='/var/lib/mlocate/mlocateishare.db' [検索語]

などとして検索ワードを調べる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment