I am trying to work with a remote device that I login to using SSH, the device uses MQTT for communication, and I want to be able to log that remotely without keeping a terminal open with the command running. Currently my command I run is shown below, but it cannot be ran without keeping a laptop connected with the terminal running.
I have read about using solutions like (nohup "command" &), but I have been unable to factor that into the below code.
mosquitto_sub -v -u Test -P Test123 -t '#' | while read -r line ; do echo -e "$(date "+%Y-%m-%d %H:%M:%S") $line" done | tee -a MQTT.txt
So to summarize I want to be able to run the above code, and detach the process from the terminal so that it will continue to run without the terminal being connected, which I believe is possible using nohup, but I also still need to log the messages to a local file so they can be reviewed later. How would I change the above code so that it is possible to do that?