Get stdout and stderr of a nodejs application running in background as process - node.js

there is an existing nodejs code on a ubuntu server running in the background. This existing code is having some issues and I want to see the console.logs of this code running.
I have found the process id of by:
ps -aef | grep node
which gives
aman 20897 1 0 Sep26 ? 03:07:06 node Monitor/Broker.js
Can someone help with how do I find the logs/stdout/stderr for this process ?
Thanks
edit
output of lsof -p 20897

Related

centos | perl processes are not shown

I have a centos server in which I have install perl package to run some perl scripts. today I run some perl scripts, and when I run ps -ef | grep perl it shows nothing although the scripts are working properly.
When I use pkill -f (name_of_script) the perl process stopped however they are not shown at all.
Note that yesterday I deleted a user ( X ) which was affected to folder /home/scripts. What do you think the problem is from?
The reason for not showing the process in ps -ef might be due to the process being run as a background process. In that case, the process won't be associated with the terminal where you started it from and thus won't be shown in the output of ps -ef. To see all processes running on the system, including background processes, you can use ps aux instead.

Display PID and Port of running processes

I have a task where I have to display the PID and Port number of running processes/tasks in Linux. What I have done so far is:
ps -ef | awk '/[t]ick/{print "PID="$2" "$9}'
Can anyone tell me how do I also display the port of the returned results? Here is what Im getting returned currently:

Is it possible to connect to running NestJS server stderr/stdout?

I'm not sure if it's possible, but I want to connect to existing application to see what logs it produce in realtime. Is it possible to do so from Linux terminal?
If you know the pid of the process (it should be in the start up logs, or retrieved via a ps aux | grep <port> call) you should be able to tail it via tail -f /proc/<pid>/fd/2. Command found from here

How can I use ubuntu service to make a process persistent?

I am not convinced that is the right terminology but here is my situation.
I log into an Ubuntu server using ssh and start a node app that I wrote. I would like for the app to continue rinning even when I close the ssh window or when the window times out. I 'think' there is a way to do this by writing a .conf file for the app and placing it in /etc but I dont know where to go to learn how to do that.
Any tips?
You can use the program nohup to accomplish this. It is most likely already installed on your Ubuntu distribution, it was on my 12.04 install.
nohup node test.js &
This command kicks off node test.js. Output will be streamed to nohup.out so you can view what is has been doing later on if you so like. Even after the ssh session is ended, the process will keep right on going.
To kill the process later on, you can do a "killall node" or you can manually grep for the PID and kill it that way using "ps -ef | grep node"
Linux: Prevent a background process from being stopped after closing SSH client

Best way to start JBoss AS

I like to ask what is best way to start jboss AS.
Because, whenever i close terminal or press ctrl+c then jboss, which is already started with run.sh script, start with shutdown. I have already tried executing export LAUNCH_JBOSS_IN_BACKGROUND=1 before starting jboss via script .run.sh but it has not helped me much.
Secondly, i like to know how can i validate that jboss is running except browsing localhost:8080 or localhost:8080/admin-console.
I am using both mac-osx/linux and Jboss-AS-6.0.0.Final.
nohup /usr/local/jboss/bin/run.sh -b 0.0.0.0 > /dev/null & should do starting jb as well running it in background.
You can check for jboss running using ps -ef | grep java
For the first part of the question, try running:
./run.sh &
This will send the process to the background. Just hit enter once JBoss has finished starting up.
If you need to bring the process back to the foreground, run fg. You can then hit CTRL-C if you want stop JBoss.
To validate that jboss is running, you can run something like this :
ps -ef | grep jboss
or
ps -ef | grep run.sh
This will show the process id for JBoss or the run.sh script.
I hope this helps.

Resources