在后台运行linux串行脚本

发布于 2024-10-04 22:09:48 字数 212 浏览 1 评论 0原文

我正在运行一个简单的脚本来连接到电力监视器的串行端口并将输出保存到文件中:

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

我理想情况下希望将其设置为在后台运行并使其保持运行,我想我可能需要一个守护进程为了这?有人有使用 cu 无人值守的经验吗?

谢谢, 劳伦斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜光 2024-10-11 22:09:48

您可以像这样使用 dtach ( http://a.com.gt/rYL )

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

这将像“后台”一样运行该进程。您可以关闭终端或结束 ssh 连接,它会一直运行,直到您取消为止。

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.

天涯沦落人 2024-10-11 22:09:48

我以前没有使用过 cu,但一般来说,您可以通过在命令后面添加 & 来使命令在后台运行。

例如

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

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 &
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文