How to clear out locked files
If the file that is locked is a study file (Qff, Quo, Tr, Fon, or Fnx) then it is likely the study server has the file open and you want to first try to bring it down from the server. If the file is NOT a study file, you can skip this first section and jump to Section title finding the process that has the file open.
Closing Study Files from the Server
If you have access to a terminal mode Supervisor, go in and do a dis to see what studies are loaded.
If the study is on the list of loaded studies, then for sure the study server has those study files locked.
Then check to see if there are any interviewers active on it.
If there are no interviewers active on the study, you can shut it down with the SDS or server:clearstudynow commands. If it is a web study, you probably want to also deactivate it so that it is not accidentally started again while you are working with the files.
If there are interviewers on the study, are they real interviewers with interviews in progress, or could they be hung stations or just stations where the interviewer did not log out properly? If they are not real interviewers, then clear them out either by going to each station and logging them out or use the clear and/or server:clear commands from the Supervisor.
If they are real interviewers, then someone needs to decide if the study should or should not be brought down to give you access to those files.
Finding which process has the file open using lsof
First typelsof and if comes back with “Command not found” or similar error, then it is not in your path. If it echoes back a bunch of information, or actually anything other than an error, then it is the path.
If it is NOT in the path. try typing
locate /lsof
if it exists on the system it will echo back with something like this.
/usr/sbin/lsof
It may print other lines under it, but as long as you have the one above, it should exist on your system.
Now type /usr/sbin/lsof or whatever the full path to the file is.
/usr/sbin/lsof
and it should echo back with a bunch of information. If you get an error, there may still be permissions problem for you to access that program.
If you either cannot find lsof or if you do not have access to it, you’ll need to contact your system administrator.
If you can get access to lsof, then point it at the file that is locked.
/usr/sbin/lsof ${CFMC}qff/<studyname>.qff
It should echo back with the process ID of any process that has the file open. Display should look like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
stdysrvr 16592 cfmc 9rr REG 253,0 4456089 24839572 /cfmc/test8.6/fone/test.fon
Log back into the terminal Supervisor and try the command
server:showfiles
this should produce a listing on the screen of all the study files the server has open. If you see one of the files for the study on the list.
Then type
>dump O9
be sure the O is capitalized.
then proceed with caution, but the following command will close all files on the study server associated with the study name used below. If you have similarly names studies, be sure to use the proper name.
server:cleanout <study>
This should remove all references to files with that name in it. You can redo the server:showfiles command to verify the server no longer has it open.
Killing a process from the LINUX command line
If the process that has the file locked is NOT the study server, then you likely need to kill that process. The display might look like this:
survent 16595 cfmc 9rr REG 257,0 4453324 26789112 /cfmc/test8.6/qff/test.qff
The PID (process ID) number in the 2nd column can then be used to kill the process. You must either be logged in with the same user name as owns the process or root. If you are not the same user name and do not have access to root, you will need to contact your system administrator.
To kill the processes, use the LINUX system command kill -9.
NOTE: BE CAREFUL when using this command. It will kill whatever process is associated with that number no matter what the process is currently doing. If you kill a live process everything associated with that process will be lost. If you were to accidentally kill the study server process you could bring the entire interviewing shop down. Be sure to double and triple check the process id that you typed in is in fact the one you want.
kill -9 16588
If the kill command works, no message will be printed. If the number you entered does not belong to a valid process, then it will return with an error saying there is no such process.
You can redo the lsof command when you are done and there should no longer be any processes attached to it.