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 current progress thus far.
On Linux, I have used lsof -n | fgrep cron (lsof is similar to BSD’s fstat), and it seems like I might have found the file, but it is annotated as having been deleted (a standard practice for temporary files is to be deleted right after opening):
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ... cron 21742 root 5u REG 202,0 7255 66310 /tmp/tmpfSuELzy (deleted)
And cannot be accesses by its prior name anymore:
# stat /tmp/tmpfSuELzy stat: cannot stat `/tmp/tmpfSuELzy': No such file or directory
How do I access such a deleted file that is still open?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The file can be access through the /proc filesystem: you already know the PID and the FD from the lsof output.
cat /proc/21742/fd/5
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0