BLOG(6)BLOG MANUALBLOG(6)
NAME Tail foreverjs logs SYNOPSIS

Forever is "a simple CLI tool for ensuring that a given script runs continuously (i.e. forever)."

DESCRIPTION

Forever includes a command ( $ forever logs 0 ) to show you the last 100 lines of stdout/stderr for the processes it is watching. Often 100 lines is enough to see what you were hoping to see.

But sometimes 100 lines is not enough and instead you would like to see a live tail of the forever watched process. Linux/Unix based operating system tools to the rescue!

Running $ forever logs (assuming you are only watching a single process) will emit 3 lines of output. The third line contains the full path to the log file. Knowing this we can construct a simple pipeline:

$ forever logs | awk 'NR==3' | awk '{print $4}' | xargs tail -f

Above, forever emits its output => awk grabs the 3rd line using it's "number of record/NR" syntax => another awk prints the 4th space delimited string from that line (the path) => and finally xargs takes that and runs tail -f(ollow)!

Familiarity with these *nix tools is infinitely reuseable as plain text is the most common protocol and these tools are purpose built for working with text.

BUGS

2020-04-16 Edit: If you are running a version more recent than v0.14.1 released Jul 1, 2015, there's a built-in flag to tail logs. :facepalm:

$ forever logs 0 -f

SEE ALSO      appletonmakerspace(1), github(1), instagram(6), mastodon(6), wisconsinlinux(1), youtube(6) AUTHORS Mike Putnam mike@theputnams.net FILES2023-12-09-100-hours-1000-kilometers2017-07-06-whats-going-on-in-tech2017-04-26-git-blame2016-10-27-choose-your-own-adventure-lockin2016-09-23-the-zen-of-python2016-07-18-organize-your-docker-stuff-with-labels2016-02-15-tail-foreverjs-logs2015-06-30-coder-cooperative2014-09-28-learning-to-weld2014-05-04-a-copper-thing2014-05-01-openbsd-55-released-today2014-04-30-what-to-make2013-10-10-appleton-makerspace-grand-opening2012-11-11-dell-xps-13-ultrabook-running-openbsd-snapshot2011-09-28-why-i-love-barcamp2011-07-04-a-simple-python-grep2011-05-08-dhmn-candybot-won2011-04-14-milwaukee-makerspace-grand-opening-road-trip2011-03-17-what-the-heck-is-a-barcamp2011-02-21-arduino-mosfet-irobot-wheels2011-02-05-dhmn-make-session2011-02-01-gladiator-girl2011-01-31-toward-an-appleton-wi-makerspace2011-01-24-madhackerhaus-12011-01-16-a-timelapse-doodle2010-11-07-arduino-happy-birthday-emitter2002-07-08-self-hosted-linux2002-04-08-geocaching More posts... (press for help or to quit)
BLOG(6)BLOG MANUALBLOG(6)
Mike Putnam