You have multiple terminals (in most Linux based distros, but maybe not in the Raspi OS) in which you can run background stuff, you may switch between them using CTRL+ALT+F1 to F6, the desktop session usually runs in F1: Try to click CTRL+ALT+F2 - this will switch terminal, you return with CTRL+ALT+F1. This would be the cumbersome way of doing it, creating a systemd service which runs on boot and continues to run until shutdown would be the "make and forget" solution:
Create a file named "/etc/systemd/system/logudp.service" and add the following content:
Code: Select all
ExecStart=/usr/bin/sh -c "nc -u -l -p 4222 >> /home/pi/events1.log"
After the file has been created, run "sudo systemctl enable logudp" to enable the service for automatic startup on boot and "sudo systemctl start logudp" to start it immediately. You can make multiple services to run multiple tasks.
EDIT: Added /usr/bin/sh to be sure..