简体   繁体   English

我可以在Pi上运行脚本并在关闭SSH时使其继续运行吗?

[英]Can I run a script on my Pi and keep it running when I close SSH?

I have a Raspberry Pi running Debian Lite (terminal only, no desktop). 我有一个运行Debian Lite的Raspberry Pi(仅限终端,没有桌面)。 I've installed Node.js and am currently running a script by making an SSH connection through puTTY. 我已经安装了Node.js,目前正在通过puTTY建立SSH连接来运行脚本。

The problem is, when I close the puTTY window the script stops running. 问题是,当我关闭PuTTY窗口时,脚本停止运行。 I need it to run when my desktop is turned off, otherwise having it on the Pi is pointless. 我需要在桌面关闭时运行它,否则在Pi上安装它毫无意义。

So far I have tried: -Nohup | 到目前为止,我已经尝试过:-Nohup | Appended the output but still stopped running when I closed the terminal. 追加了输出,但是当我关闭终端时仍然停止运行。

Multiple options: 多种选择:

Install screen or tmux on the PI and start the job with those programs. 在PI上安装screentmux ,然后使用这些程序启动作业。

(or) Run the job with the nohup command: (或)使用nohup命令运行作业:

nohup command

(or) Run the job in the background and use disown : (或)在后台运行作业并使用disown

command &
disown %1

I recommend option 1. 我建议选择1。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关闭终端或我的ssh会话后,我无法保持服务器运行 - I can't keep my server running once I close terminal or my ssh session 我的 deploycommands.js 文件在我使用脚本时没有运行,当我手动运行它时抛出错误 - My deploycommands.js file is not running when I use a script and throwing an error when I run it manually 当我关闭 Putty 的会话时,Nodejs 停止运行 - Nodejs stop running when i close my Putty's session 当我将 SSH 插入我的 EC2 实例时,我如何确定它当前正在运行什么服务器? - When I SSH into my EC2 instance, how do I figure out what server it is currently running? 我可以将node.js脚本输出管道输入`less`而不输入`| 跑的时候少吗? - Can I pipe my node.js script output in to `less` without typing `| less` when run? 尝试在 VS 代码中的终端中运行“npm start”时,我一直遇到同样的错误:npm 无法找到文件。 我应该怎么办? - I keep running into the same error when trying to run "npm start" in my terminal in VS code : npm not being able to find a file. What should I do? 我是否需要让我的脚本运行以便 node-cron 执行计划任务? - Do I need to keep my script running for node-cron to do scheduled tasks? 当我运行我的脚本时,它输出 mml2tex is not a function - When I run my script, it outputs mml2tex is not a function 我怎样才能进入我的流星应用程序? - How can I ssh into my meteor app? 我应该保持提示始终打开以运行预定的 node.js 脚本吗? - Should I keep my prompt always open to run the scheduled node.js script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM