Dealing with files that are currently opened in a program

learn more… | top users | synonyms

1
vote
1answer
49 views

Read “/proc” to know if a process has opened a port

I need to know if a process with a given PID as opened a port without using external commands. I must then use the /proc filesystem. I can read the /proc/$PID/net/tcp file for example and get ...
2
votes
0answers
45 views

Can file handles be translated to filenames?

Is there a tool for translating file handles to file names on Solaris 10? I've looked around and found several scripts including the one at: http://heim.ifi.uio.no/kjetilho/hacks/fhfind.perl ...
2
votes
0answers
56 views

“Too many open files ssh” when the number of open files is far below ulimit

I was trying to set up 2000 concurrent ssh connections, but got the error message in server log (i.e. journalctl): sshd[1356]: error: reexec socketpair: Too many open files I've set both the soft ...
13
votes
4answers
582 views

`ls` error when directory is deleted

I have two shells open. The first is in directory A. In the second, I remove directory A, and then recreate it. When I go back to the first shell, and type ls, the output is: ls: cannot open ...
3
votes
3answers
1k views

Best way to free disk space from deleted files that are held open

Hi I have many files that have been deleted but for some reason the disk space associated with the deleted files is unable to be utilized until I explicitly kill the process for the file taking the ...
7
votes
1answer
1k views

Why file-nr and lsof count on open files differs?

I am running into a problem all of a sudden; all my applications and the server was running fine and all of a sudden I see the number of open files shoot up. I am checking it with this command: cat ...
6
votes
2answers
818 views

Move file but only if it's closed

I want to move large file created by external process as soon as it's closed. Is this test command correct? if lsof "/file/name" then # file is open, don't touch it! else if [ 1 -eq ...
2
votes
1answer
127 views

Find out to which directory a process is writing?

This question is NOT a duplicate of this question Find out current working directory of a running process?, because the writing directory can be different from the working directory. For example, I ...
1
vote
1answer
204 views

Number of open file descriptors won't change when I set them in CentOS 6.3?

uname -a Linux lab.testing.com 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux ulimit -Hn 1024 ulimit -Sn 1024 ulimit -n 1024 I opened /etc/sysctl.conf in vi and added ...
25
votes
2answers
1k views

Is it safe to move a file that's being appended to?

I have a node.js process that uses fs.appendFile to add lines to file.log. Only complete lines of about 40 chars per lines are appended, e.g. calls are like fs.appendFile("start-end"), not 2 calls ...
5
votes
1answer
159 views

How to make sure only one instance accessing the file at a time in a folder?

I have a shell script which will be executed by multiple instances and if an instance accessing a file and doing some operation how can I make sure other instances are not accessing the same file and ...
1
vote
1answer
845 views

Daemon's open file limit is reached even though the system limits have been increased

I am running Debian wheezy. File limits are increased to 100000 for every user. ulimit -a and ulimit -Hn / -Sn show me the right amounts of maximum open file limits even in screen. But for some reason ...
10
votes
2answers
2k views

Why does process substitution result in a file called /dev/fd/63 which is a pipe?

I am trying to understand named pipes in the context of this particular example. I type <(ls -l) in my terminal and get the output as, bash: /dev/fd/63: Permission denied. If I type cat <(ls ...
7
votes
3answers
722 views

How can a log program continue to log to a deleted file?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section: If an active process has the file open (not uncommon for log files), removing the file and creating a new ...
15
votes
2answers
1k views

How to find out what process is writing to STDOUT?

I have two instances of a process running. One of them is "frEAkIng oUT!" and printing errors non stop to STDOUT. I want to kill the broken process but I have to make sure I don't terminate the wrong ...
15
votes
3answers
2k views

How do I “cat and follow” a file?

A file is being sequentially downloaded by wget. If I start unpacking it with cat myfile.tar.bz2 | tar -xj, it may unpack correctly or fail with "Unexpected EOF", depending on what is faster. How to ...
2
votes
0answers
151 views

ls does not show a hidden file (OS X)

I am using lsof to view the list of open files. One such file that it displays open is : Google 3864 malaykeshav 46u REG 1,1 470455334 32578671 ...
3
votes
3answers
126 views

Moving an open file to a different device

I have an application running that is generating a large (~200GB) output file, and takes about 35 hours to run (currently I'm about 12 hours in). The application just opens the file once then keeps it ...
1
vote
1answer
131 views

Prevent active file removal on an NFS filesystem

I clear my logs using following script - find "." -mtime 1 -type f -print0 | xargs -0 rm -rf But it deletes the active files also and creates .nfs… files instead. Is there any way to prevent ...
2
votes
1answer
2k views

How to configure the process open file limit of a user?

The default open file limit per process is 1024 on - say - Linux. For certain daemons this is not enough. Thus, the question: How to change the open file limit for a specific user?
5
votes
3answers
882 views

tail -f, Determine if a file is no longer being written to [closed]

I am using tail -f to follow the growth of a log file. I am having trouble finding a way to detect if the process that is writing to the log file (when it crashes or is otherwise terminated) is no ...
5
votes
2answers
1k views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
1
vote
0answers
318 views

Which process is occupying a certain pseudo terminal pts/X?

On Linux: Normally pseudo terminals are allocated one after the other. Today I realized that even after a reboot of my laptop the first opened terminal window (which was always pts/0 earlier) ...
1
vote
1answer
456 views

If I open the same file twice in Okular, switch to the existing window

I have always been confused why the file manager in Linux cannot stop applications from opening a single file twice at the same time? Specifically, I want to stop the PDF file reader Okular from ...
1
vote
1answer
177 views

If file does not get closed, will OS close it?

If a file is being opened by a process and it is not being closed by any of the processes, will the OS automatically close that open file?
0
votes
1answer
132 views

“Open file” dialog: Focus jumps to text field (LMDE / Cinnamon)

I have a usability problem with the "Open file" dialog. The questions would be: Is there any way out? E.g. can I disable the autocomplete? Otherwise, I might post a bug report.. Why does this ...
3
votes
2answers
200 views

File permissions and saving

Let's say you open a file on which you have write permission. Meanwhile you change permissions and remove write permission while you still have the file open in some editor. What will happen if you ...
5
votes
3answers
3k views

What process is accessing a mounted filesystem sporadically?

I have a Solaris 10 server with autofs-mounted home dirs. On one server they are not unmounted after the 10 min timeout period. We've got AUTOMOUNT_TIMEOUT=600 in /etc/default/autofs, I ran automount ...
3
votes
2answers
78 views

Bizarre Disk Use Problem

I have an external hard drive on which I use rsync to backup my home directory. Today, I tried to umount the drive. It said it was busy. So, I used fuser to figure out who was using it: /media/Panp9 ...
1
vote
2answers
102 views

Tracking which files are used by program

I am looking for a way to track which files are used by program installer(InstallAnywhere). I cannot use lsof because as far as I know it works on active processes and I want a tool which will work ...
1
vote
1answer
422 views

Strange behavior in mv command - maybe open sys call issue?

I'm noticing very strange behavior from the "mv" command that may (or may not) be related to the "open" system call. We're running RedHat v5. There are two separate storage devices, one mounted to ...
3
votes
4answers
35k views

Show running processes with file name(s)?

I am using putty to connect my linux server which my sites are in. I can run # ps aux | less to show running processes. But I want to display which files running these processes ? I have also ...
27
votes
3answers
48k views

Find and remove large files that are open but have been deleted

How does one find large files that have been deleted but are still open in an application? How can one remove such a file, even though a process has it open? The situation is that we are running a ...
4
votes
1answer
223 views

lsof doesn't return files open by the same user

Consider this simple scenario: I open a text file ~/textfile.txt with vim in one terminal (tried with both edit and read-only modes). In a different terminal, I run /usr/sbin/lsof ~/textfile.txt ...
3
votes
1answer
548 views

How can I access a deleted open file on Linux (output of a running crontab task)?

I have an hourly hour-long crontab job running with some mtr (traceroute) output every 10 minutes (that is going to go for over an hour prior to it being emailed back to me), and I want to see the ...
4
votes
1answer
270 views

Using xdg-open for accessing network with normal explorer

I'm working with small network and I want to start network explorer from a terminal. When I tried to type xdg-open network:///server it opened google chrome and did nothing. I also tried to type ...
15
votes
1answer
6k views

How do I monitor opened files of a process in realtime?

I know I can view the open files of a process using lsof at that moment in time on my Linux machine. However, a process can open, alter and close a file so quickly that I won't be able to see it when ...
2
votes
1answer
172 views

vim not shown in fuser

First use Vim to edit a file, say /tmp/A. Assuming that vim process is the only one that accesses /tmp/A, then use "ctrl+z" to suspend the process, and execute fuser /tmp/A Then you see nothing ...
2
votes
1answer
192 views

Max Open Files, clarification needed

On my machine, ulimit -n returns 2560 Given that -n returns The maximum number of open file descriptors. Does it mean that system won't allow more then 2560 open files to be out there at any ...
8
votes
3answers
3k views

How to switch to the directory listing from file view in vim?

I have opened a dir vim some/dir. I can navigate within the tree, yet once I opened a file I wonder, how do I close the file view in order to go back to the directory listing to navigate to another ...
2
votes
2answers
2k views

File delete versus overwrite and link at /proc/pid/fd

It is well known that UNIX systems won't actually delete a file on disk while the file is in use. So if a file is being accessed by process 1 and process 2 deletes the file using rm, process 1 ...
1
vote
0answers
93 views

how to open a knote file on knote

I was wondering if there is any way to open a knote file within knote. There is a knote save option but I am not sure how to open one. Any ideas? Any other program that could open .ics files?
4
votes
2answers
8k views

File descriptor linked to socket or pipe in proc [duplicate]

Possible Duplicate: /proc/PID/fd/X link number i have a question regarding the file descriptors and their linkage in the proc file system. I've observed that if i list the file descriptors ...
3
votes
1answer
161 views

Efficient mechanism to determine if open file has been externally modified?

For example, the IDE I'm using at the moment (Aptana Studio) notifies me as soon as a file's contents it has open have been changed by some external program. I can imagine having a periodic loop run ...
5
votes
1answer
1k views

Which command will open the default browser on a system to a given web page (terminal)?

Title says it all. Is there a way to open the default browser on a user's system to a specific page from within a Bash script, or other-language script?
1
vote
1answer
281 views

What happens if a cron script tries to copy a directory at the same time as another process is writing to it?

For example, if I have a java process that (once every 2 hours) takes a backup of a large file, like 500mb, and places it into folder A on HDD A, and I want to schedule a cron script to copy the ...
30
votes
3answers
40k views

Why is number of open files limited in Linux?

Right now, I know that: Find open files limit per process: ulimit -n Count all opened files by all process: lsof | wc -l Get maximum open files count allowd: cat /proc/sys/fs/file-max My ...
5
votes
1answer
421 views

How can I configure OpenBox session for opening files by mime type?

I've started using OpenBox and I really like it. But my chromium opens everything with firefox. Is there any fix for that? I'm looking for most lightweight solution, but also with easy and fast ...
13
votes
2answers
3k views

How to find out the file offset of an opened file?

My problem is that with lsof -p pid I can find out the list of opened file of a process whose process id is pid. But is there a way to find out the file offset of each accessed file ? Please give me ...
6
votes
2answers
4k views

Change default applications used by gnome-open, exo-open, xdg-open, gvfs-open and kde-open

How to change the applications associated with certain file-types for gnome-open, exo-open, xdg-open, gvfs-open and kde-open? Is there a way by editing config files or by a command-line command? Is ...