I am trying to automate Forever JS to keep my dev server running and for that I need to check and stop the forever process to start another one. By running
sudo forever list
I get the following output:
info: Forever processes running data: uid command script forever pid id logfile uptime data: [0] 0NQH /usr/bin/nodejs app.js 17047 17049 /home/ubuntu/.forever/0NQH.log 0:2:4:58.594
From the above output I need the pid which is 17049 currently and feed it to the next command like so:
sudo forever stop {{pidfromabove}}
To accomplish this, in my script I've tried out many things, mainly trying to find the two strings between app.js and /home but for some reason it keeps printing the whole line. I've tried different combinations of sed and awk. How do I get the pid from the above to feed to the next stop
command?