Monday, October 10, 2022

[SOLVED] Running linux serial script in background

Issue

I'm running a simple script to connect to the serial port of my electricity monitor and save the output to a file:

cu -s 57600 -l /dev/ttyUSB0 >> /var/www/power.txt

I'd ideally like to set this off going in the background and leave it running, I think I might need a daemon for this? Does anyone have any experience using cu unattended?

Thanks, Laurence


Solution

I haven't used cu before, but in general you can make a command run in the background by putting & after it.

e.g

cu -s 57600 -l /dev/ttyUSB0 >> /var/www/power.txt &


Answered By - Angus
Answer Checked By - David Marino (WPSolving Volunteer)