我见过有人说使用屏幕。
但是当我在终端中输入“screen”时,我得到:“请设置终端类型。”
知道我该如何解决这个问题吗?
答案1
要回答您最初的问题,注销后保持命令运行的最基本方法是使用 nohup 命令运行它。
例如,如果我想运行一个脚本,并将其放入后台,同时在注销后保持其运行,我将输入:
nohup ./myscript &
更多信息可以在这里找到:https://en.wikipedia.org/wiki/Nohup
否则,正如您所说,屏幕是一个不错的选择。
答案2
解决方案1:
If you want to run screen , these are the way :
Login to your user :
-- To create a new session for screen
screen -S screenname
-- To detach from the screen
Ctl + ad
-- To reconnect to screen :
screen -dr screenname
-- To check the current open screens :
screen -ls
-- While in screen , you can use
Ctl + ac (to create new screenwindows)
Ctl + an (move to next screenwindow)
Ctl + ap (move to previous screenwindow)
解决方案2:
You can run a script like this :
/fullpath/to/script/scriptname.sh >> /fullpath/to/log/logname.log 2>&1
Ctl + z
bg %1 (run in background)
disown %1
-- To check if its running :
ps -ef | grep scriptname.sh
注:这里的Ctl表示控制键