C
C
celovec2020-12-11 14:34:02
Command line
celovec, 2020-12-11 14:34:02

How to monitor the logs of a running program in the console?

I run the program in the console:
./programma &
the & symbol says to run it in the background. But at the same time, I see logs from it in the console.
If I close the console and open it again, I will no longer see these logs.
Q: How do I get hooked on the program and watch them again ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Saboteur, 2020-12-11
@celovec

1. Use nohup - then the program will not only run in the background, but also get rid of your console, and the logs will automatically go to the nohup.out file
nohup ./programma &
2. Run the program in the background with output redirection

./programma >programma.log 2>programma_errors.log &

3. Run the program in the background with output redirection and through nohup, then the program will go into the background, get rid of the console, but you can specify specific log file names
nohup ./programma >programma.log 2>programma_errors.log &

4. You can throw standard output and error output into the same file:
nohup ./programma >programma.log 2>&1 &

R
res2001, 2020-12-11
@res2001

Write a service config for systemd and run your chat as a service through standard OS mechanisms. Logs will be written to a file in /var/log. Logging can be configured so that there is a separate file for your application.
Systemd service configs in Ubuntu are located in /lib/systemd/system files with .service extension. You can take one as an example.

D
Dmitry Belyaev, 2020-12-11
@bingo347

https://wiki.archlinux.org/index.php/GNU_Screen_(P...
https://wiki.archlinux.org/index.php/Tmux

B
BorLaze, 2020-12-11
@BorLaze

nohup ./programma &
log watch (what immediately, what after reopening the terminal)
tail -f nohup.out

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question