This question already has an answer here:

I've started a long running process with nohup and redirected it's output to a log file


nohup ./bin/zkServer.sh start-foreground > /usr/local/myuser/logs/zkout.log 2>&1 &

I accidentally deleted the zkout.log file so now I can't see any output from the command.

I'm not interested in recovering the data, but I am wondering if there is a way to 'reattach' the stdout from my long running process to the file without having to kill/restart?

I tried just recreating /usr/local/myuser/logs/zkout.log but that doesn't work.

I also looked at this question: recovering deleted file held open by apache? but that is talking about recovering the content of the deleted file (which I don't care about). However, I do see the broken link in /proc/$procid/fd; could I just update that link to point to the new file?

marked as duplicate by Gilles files Apr 21 '16 at 22:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • How good are you with gdb ? – thrig Apr 21 '16 at 16:58
  • @thrig never used it. If there's not an easy way to do it I'll have to kill and restart; not a huge deal just thought there might be something simple I didn't know about. – FGreg Apr 21 '16 at 17:02
  • 2
    I believe what you're looking for is answered here unix.stackexchange.com/questions/92816/… – SeeJayEmm Apr 21 '16 at 19:18