This is my first question ever on Stack Exchange! Ive been using it for years and always seem to find my solution, except for this one.
I am trying to get top to run in a seperate screen so I can monitor the performance of a single process in the background. I have named the screen instance to enable me easily attach to it when I need to. I have put all this in a script as it is all part of a larger monitoring experiment i'm trying to run, it goes something like this.
screen -S TOP -D -m top -b -p $PID > top.log &
What this should do is that it should create a new screen session called top, then detach from it on creation and run the top command such that creates a binary file top.log and put it in the background.
Everything works fine except the file is created but is not populated with any top data, whereas when I run the command without screen it works fine.It looks like screen isnt regarding the redirection as part of the top command but is creating the file anyways, maybe as part of a separate command.
For now, I've defaulted to using nohup to run top in the background, but I would very much like to be able to attach to the screen.
Any ideas?