0

So this is a bit of a multi part question, I have a vps that I connect to through ssh to run a few processes on.

I would like to be able to start the processes and close my terminal window but still be able to ssh back in and check on the processes.

I would also like each process to output whatever it prints to the terminal to a file, ideally named after the command that started it. (including flags and such)

how do I best achieve this goal?

1

1 Answer 1

0

There is possibly multiple ways of achieving it, but here are some of essentials:

screen

screen allows to create virtual console, deattach it from your tty (CTRLA followed by CTRLD) and attach it back (screen -r) anytime you need.

nohup

nohup is a software which allows you to run command which will ignore any hangup signal and write output of command to nohup.out file in cwd. In practice running following command thought ssh and then logging out will keep process working nohup dd if=/dev/random of=/dev/null &.

tee

tee command in very simple usage works as a fork machine which write it's stdin to a file and to stdout simulateously. In your case that would be ls -alh | tee 'ls'. If you also want to write stderr to file append 2&>1 (which means "redirect stderr to stdout") to your base command.

By combining these solutions you should be able to achieve what you want. You can also see similar answer: 8703001/1732775.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .