Decorate tail output with timestamps
I often use nohup
to run long running tasks in the background on servers. For eksample for reindeksing operations or compiling.
The benefit of nohup is that the process is not stopped if you lose connection or close the terminal window.
Since nohup writes the output to file I use tail -f nohup.out
to display the output as it happens.
Because it's often process that takes a long time then it's sometimes useful or nice to know when things happen. Using xargs we can pipe the output from the tail command into the date command and add timestamps.
1tail -f nohup.out | xargs -IL date -u +"%FT%TZ: L"
Note: date -u +"%FT%TZ"
outputs zulu time.
Written by Eivin Landa • February 11, 2022 • Updated March 24, 2022