Cass
0
Q:

screen: recover deleted running script

## How to recover a running script from a terminal session
## If a running program still has the deleted file open,
## you can recover the file through the open file descriptor
## in /proc/[pid]/fd/[num].

## To determine if this is the case, you can attempt the following:

#look for the script's pid using ps

$ ps -ef|grep script.sh


# you should get an output like this:

# Fdo  8983  8463  0 12:28 pts/2    00:00:00 /bin/bash ./script.sh

## take note of the PID (8983) in the second column,
## Using this information you can recover the file by issuing the command:

$ cp /proc/8983/fd/255 /path/to/restored/file.txt

## the 255 is basically use for deleted files.
## you can now open /path/to/restored/file.txt there you'll see the 
## content of the deleted file.

#Good luck
0

New to Communities?

Join the community