0

On UNIX systems, if a file lock is held, the error message includes a PID, eg:

ERROR: A lock is not available for XXX.XXXX.

ERROR: Lock held by process 4653302.

For windows, the guilty process is not provided. Is there a way I can find out who locked the table? I cannot log onto the machine, however the server does have XCMD enabled.

FWIW, the FILELOCKWAIT option is not helpful here (it's a long running lock).

EDIT: I am not an administrator, and I cannot download third party tools

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
  • Have you considered any of the options [here](https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows/399660#399660) or [here](https://stackoverflow.com/questions/241178/command-line-tool-for-finding-out-who-is-locking-a-file)? – user667489 Feb 12 '19 at 10:48
  • Thanks for the suggestions, however I am unable to download third party tools and my account is not an administrator account. The powershell approach might work though - will check and get back to you, cheers – Allan Bowe Feb 12 '19 at 10:53
  • This is in a server environment (where the user(s) are presumably logged into the same server)? Or desktop with a network share? These are SAS datasets stored on a network file share and/or the local server disk? – Joe Feb 12 '19 at 19:24
  • Good point - this is on a SAS Windows Server (2012), and the datasets are on a network file share. The error message was surfaced through Enterprise Guide. – Allan Bowe Feb 12 '19 at 19:54

1 Answers1

1

wmic provides almost anything you want about the goings on in Windows.

win32_process will tell you (if your account has the proper policy settings) all about who is running what. Find the SASers and call em up ?

Example: Proc IMPORT can't read a pipe, so save the wmic output to a file first.

%let wmic_cmd = wmic path win32_process where "description like '%nrstr(%%sas.exe%%)'";

filename whosas pipe 
   "%superq(wmic_cmd) get /format:csv | findstr /r /v ""^$"" > c:\temp\wmic_whosas.txt"
;

data _null_;
  infile whosas;
  input;
run;

proc import dbms=csv datafile="c:\temp\wmic_whosas.txt" replace out=whosas;
run;

Should get you 47 pieces of info about each SAS process.

If you don't have permissions, IT will have to grant them, or get involved with you so often they eventually do :)

Richard
  • 25,390
  • 3
  • 25
  • 38
  • 1
    Note: The wmic csv format outputs consecutive commas (`,,`) and the IMPORT procedure does not pick that up, as would INPUT with DLM and DSD. Thus IMPORT data is column shifted when `,,` present in the wmic output. – Richard Feb 13 '19 at 03:51
  • indeed this finds the PID of the running sas services, thanks! unfortunately it doesn't seem possible to find out who owns that pid :-( at least not without admin rights. – Allan Bowe Feb 13 '19 at 09:45