ながれ
- locate使ってみる
- locateを更新
- locate更新(linuxのupdatedb的な)をちょっとだけ楽にする
1.ocate使ってみる
初期状態で打ってみる
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.mac:~ tweeeety$
普通に怒られる
読んだままですが、
The locate database =/var/db/locate.databaseがないとのこと。
その下にコマンドまで書いてくれているので素直に実行してみる
mac:~ tweeeety$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Password: ←パスワード聞かれるので打ってみる
mac:~ tweeeety$
とくに何も言われず。。。
うまくいったのかの確認で再度loateしてみる
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.mac:~ tweeeety$
が、だめ。
再度'sudo launchctl load -w...'もしてみる
mac:~ tweeeety$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
com.apple.locate: Already loaded
mac:~ tweeeety$
ロード済みと出るので、locate.databaseにファイル情報が書かれてないだけかな?
ということで、しばらく待つ(3分くらい)
そして再度locateチャレンジ
mac:~ tweeeety$ locate mysql
/Applications/Aptana Studio 2.0/configuration/portal.2.0.2.1261003788/images_global/img_icon_mysql.png
/Applications/Aptana Studio 2.0/configuration/portal.2.0.5.1278523018/images_global/img_icon_mysql.png
/Applications/Aptana Studio 2.0/plugins/com.aptana.ide.server.jetty_2.0.0.1278523018/content/images_global/img_icon_mysql.png
/Applications/Aptana Studio 2.0/plugins/org.eclipse.php.core_2.1.1.v20090831-1530/Resources/language/php5/mysql.php
/Applications/Aptana Studio 2.0/plugins/org.eclipse.php.core_2.1.1.v20090831-1530/Resources/language/php5/mysqli.php
/Applications/Aptana Studio 2.0/plugins/org.eclipse.php.core_2.1.1.v20090831-1530/Resources/language/php5/pdo_mysql.php
・
・
・
mac:~ tweeeety$
めでたく完了。
2.locateを更新
linuxだとupdatedbで更新できるがmacではできない
さらには自動更新に任せると週1らしい
→http://an-nai.jp/blog/771
まずは手動でupdatedb的なのする
そのまま打ってみる
mac:~ tweeeety$ updatedb
- bash: updatedb: command not found
mac:~ tweeeety$
ですよね。
↑のリンクやらにも書いてあるが
/usr/libexec/locate.updatedbをたたけば良いらしい
とりあえずsudoとかなしでたたいてみる
mac:~ tweeeety$ /usr/libexec/locate.updatedb
/usr/libexec/locate.updatedb: line 97: /var/db/locate.database: Permission denied
mac:~ tweeeety$
まぁそうですよね的な感じなので、sudoつけて実行してみる
※ちなみにだめでも1、2分かかります
mac:~ tweeeety$ sudo /usr/libexec/locate.updatedb
Password:
mac:~ tweeeety$
うまくいったぽい。
3.locate更新(linuxのupdatedb的な)をちょっとだけ楽にする
できたとはいえ、毎回これを打つのは面倒だしそもそも何打つかも覚えていられなそうなのでaliasを作ります
さっそく.bashrcにalias設定を追加
mac:~ tweeeety$ vi ~/.bashrc ←設定ファイルに書く
mac:~ tweeeety$ source ~/.bashrc ←設定ファイル反映
mac:~ tweeeety$ updatedb ←打ってみる
mac:~ tweeeety$
OKぽい。
.bashrcに加えたalias設定はこれ
alias updatedb='sudo /usr/libexec/locate.updatedb'
.bashrcはなければファイル作っちゃって問題ないです。
ってことで、無駄に長くなりましたが、無事locateができるようになりました。
updatedbが週1なのは必要になったらcronにでも設定しますか。