I've seen people saying use screen.
But when I typed "screen" in the terminal, I got: "Please set a terminal type."
Any idea how I can fix this?
I've seen people saying use screen.
But when I typed "screen" in the terminal, I got: "Please set a terminal type."
Any idea how I can fix this?
To answer your initial question, the most basic way to keep a command running after logging out is to run it with the nohup command.
For example, if I wanted to run a script, and drop it into the background while keeping it running after logging out I would type:
nohup ./myscript &
More information can be found here: https://en.wikipedia.org/wiki/Nohup
Otherwise, as you stated, screen is a good option.
setsid ./myscript </dev/null >/dev/null 2>&1
. That's a bit more similar to what a real daemon process will do. (Tweak the redirections as desired if, for instance, you want to catch output in a logfile.)
– Tom Hunt
Sep 10 '15 at 15:11
SOLUTION 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)
SOLUTION 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
Note : Ctl here means control key
echo $TERM
say on the remote box shell? – yaegashi Sep 10 '15 at 02:03TERM=<desired value>
as with any other variable, but the real issue here is why it is not getting set automatically according to your terminal type. What type of terminal are you using? – Celada Sep 10 '15 at 02:13TERM
toxterm
orlinux
orvt100
would probably makescreen
runnable temporarily. – yaegashi Sep 10 '15 at 03:29Terminal.app
from MacOS then your$TERM
setting should be reasonable by default, definitely notdumb
. Check your$TERM
setting on the local terminal. That will tell you whether it's a problem with SSH not carrying it over to the remote system or whether it's wrong on the local system in the first place. – Celada Sep 10 '15 at 12:30$TERM
value is not carrying over to the session on the SSH server, that's weird. But as a workaround you can set$TERM
to the same,xterm-256color
, instead ofdumb
, and then you will be able to runscreen
. – Celada Sep 10 '15 at 16:32