Answers for "screen: recover deleted running script"

0

screen: recover deleted running script

## How to recover a running script from a terminal session
## If a running program still has the deleted file opened,
## 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 used for deleted files.
## you can now open /path/to/restored/file.txt, you'll see the 
## content of the deleted file.

# Good luck
Posted by: Guest on August-11-2020

Code answers related to "screen: recover deleted running script"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language