English Linux nohup command

3 replies
Goto Page
To the start Previous 1 Next To the start
06.12.18 09:55:59 am
Up
macnux
User
Offline Off
Hello,

I learned that nohup command can run a command after closing the session from this article https://likegeeks.com/linux-command-line-tricks/.
Now, what about returning back and see the progress of the running command?
How can I return to see the results?

Thank you.
06.12.18 03:29:28 pm
Up
Fraizeraust
Moderator
Offline Off
nohup
will automatically output the data to a file named nohup.out which is located in the working directory (the directory location which you executed the command line). You've to use a text editor to look up at that file.

Alternatively, you can tell nohup to redirect the output to a defined file. To do so you must use the following command line below.
Code:
1
nohup some_command > output.log 2>&1&

output.log is only an example, you can replace the filename with whatever you want.
19.12.18 07:16:15 pm
Up
macnux
User
Offline Off
Thanks for the reply.
Do you mean that I can use tail -f to see the live results of the command?
20.12.18 10:44:08 am
Up
Jaller94
User
Offline Off
If you can, use
screen
. The program keeps your application alive even when you log out or lose the SSH connection.

Code:
1
screen -S my_awesome_cs2d_server ./cs2d_dedicated

Ctrl + C
to shutdown the program
Ctrl + A > D
to detach from the session (program stays alive)

To reconnect to your program, run:
Code:
1
screen -x my_awesome_cs2d_server


If the program crashes, the screen session will close too. To see which screen sessions are still active:
Code:
1
screen -ls


If you forgot to give it a name, you can connect via the process id seen in the
screen -ls
list, e.g.:
Code:
1
screen -x 1573
To the start Previous 1 Next To the start