windows后台运行命令行程序
windows后台运行命令行程序
windows后台运行命令行程序¶
背景¶
windows有时需要在后台运营cmd,以达到后台长期使用,可以借助git的
nohup cmd命令 &
完成;
示例windos在后台运行 jupyter notebook :¶
Step1 windows安装git程序:¶
Step2 : 新建.sh文件;¶
.sh文件写入以下内容
cd ~/OneDrive/python nohup jupyter notebook >> jupyter_notebook_1.log 2>&1 & ##将cmd输出信息写入到log文件中,便于后续排查错误
Step3: 双击.sh文件,由于已经安装了git程序,弹出窗口后关闭,就自动在后台运行;¶
备注说明¶
-
安装了git了,在git就可以使用
shell
语言了,相当的方便快捷; -
nohup 用途:不挂断地运行命令。&用途:在后台运行 一般两个一起用
nohup command &
-
2>&1 意思是把 标准错误输出 重定向到 标准输出.,可以写入到文件中;
-
n > file 将文件描述符为 n 的文件==重定==向到 file。 n >> file 将文件描述符为 n 的文件以==追加==的方式重定向到 file。
参考文档¶
nohup和&后台运行,进程查看及终止 – 慕尘 – 博客园
bash – In the shell, what does ” 2>&1 ” mean? – Stack Overflow