Issue
I am attempting to log UART data from my USB port to an output file. The following command works.
picocom /dev/ttyUSB0 -b 115200 | ts '[%Y-%m-%d %H:%M:%S]' >> ~/output.log
However, once I attempt to detach from this process,
picocom /dev/ttyUSB0 -b 115200 | ts '[%Y-%m-%d %H:%M:%S]' >> ~/output.log &
the command no longer works.
How can I detach from this process and let my logger run in the background?
Solution
You could use something like tmux, screen, or dtach. For example, using dtach
:
dtach -n /tmp/serial sh -c 'picocom -b 115200 /dev/ttyUSB0 > output.log'
This will start picocom
detached from the terminal; it will happily continue running until you re-attach to it and exit:
dtach -a /tmp/serial
You can do the same thing with tmux
:
tmux new-session -s serial -d 'picocom -b 115200 /dev/ttyUSB0 > output.log'
You can then re-attach to that session...
tmux attach -t serial
...and exit picocom
.
Answered By - larsks Answer Checked By - Timothy Miller (WPSolving Admin)