I am writing a bash shell script which removes a file using the following command
I handled the case of getting the prompts and providing the required 'y' or 'n' inputs.
In order to verify that the file has been removed, I validate the same by running the locate command in the following manner
Note : the desired file is present at a specific directory, so in my case this particular command is not giving me any other file's address
I noticed that despite of file being deleted, the locate command is still reflecting the deleted file's path.
I debugged the issue by manually executing each of the required commands
admin@sharad-server$ rm abc.xsl
rm: remove write-protected regular file 'abc.xsl'? y
admin@sharad-server$ locate */abc.xsl
The file was deleted as it was not reflected when I executed the ls command and also the cat command as follows
admin@sharad-server$ cat /usr/local/myserver/myapplication/lib/abc.xsl
cat: /usr/local/myserver/myapplication/lib/abc.xsl: No such file or directory
FYR my application is deployed on GCP and my server's platform details are as follows:
admin@sharad-server$ uname -a
Linux sharad-server 3.10.0-1127.8.2.el7.x86_64 #1 SMP Tue May 12 16:57:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
The details of the shell where all these commands were executed in a standalone manner are as follows:
admin@sharad-server$ ps -p $$
PID TTY TIME CMD
32296 pts/0 00:00:00 bash
Why the locate command is still reflecting the deleted file's path?
As per one of the suggestion I tried the updatedb command as well but it gave me an error.
updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'
The updatedb command worked with the root user and has successfully updated the locate command functioning.