Why the locate command still doesn’t work after it’s installed


Why the locate command still doesn't work after it's installed

WeChat public address:51 yards of rural network
Professional programming Q & a community

The locate command has been installed. Yum install mlocate still fails to work. The error message is as follows:

[[email protected] 51mn]# locate 51.txt
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

This is because locate’s search database is created by another program called updatedb, which is usually executed periodically as a cron task. The so-called cron task is the task executed by the cron daemons in a specified period. Most systems with locate command execute the updatedb command once a day. You try the next day and find that the locate command is available. That is to say, the search database of locate is not updated in real time. To take effect immediately, use the root user to manually execute the updatedb command.

[[email protected] 51mn]# updatedb
[[email protected] 51mn]# locate 51.txt