Running linux serial script in background
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
You can use dtach ( http://a.com.gt/rYL ) like this
dtach -A /tmp/cu cu -s 57600 -l /dev/ttyUSB0 >> /var/www/power.txt
This will run the process like in "background". You can close the termial or end your ssh connection and it will run until you cancel it.
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 &
精彩评论