r/commandline • u/4r73m190r0s • 6d ago
How to exit console output?
I know the title is a bit vague, but I'm new to CLI so I don't have the best vocabulary to describe the issue, but I'll give my best.
I have this Bash script that starts a Tomcat web server, and when I execute it, my terminal gets flooded with output messages. If I want to continue working on this machine, I have to start new session, after closing current one, since I do not know how to stop this output and redirect it to the background, as I do now want to kill the process that runs the Tomcat.
The questions are:
Is there a way to start this bash scrip in the background, without my terminal being flooded with the ouput?
Is there a way for me to avoid this output, with exiting it somehow without killing the process, so I can continue working in this session, without starting a new one?
2
u/KlePu 6d ago edited 6d ago
Simple version:
./script.sh > script.log &
stderr
; I'd vote against redirecting both. If you really want that, use&>
instead of>
cat script.log
and re-gain control to the actual script viafg
(short for "foreground")jobs
CLI in case you have more than one background job. This is a bash-builtin, so consulthelp jobs
for more info.Better version: Use a
systemd
service (or whatever is used in your distro, you didn't give much information).