Execute command without terminal output
Solution 1
If you don't need the output at all then redirect it to /dev/null
yourcommand > /dev/null 2>&1
otherwise you can redirect into a file:
yourcommand > /somwhere/file 2>&1
And as you run the command from another application and you want use your news reader immediately you may want to run the command in the background. I am not sure how it works in this newsboat, but in a shell you can send programs into the backround with &
yourcommand > /somwhere/file 2>&1 &
Solution 2
To run command silently in background, which will "survive" even if terminal will be closed afterwards, use screen
in detached mode:
screen -dm your_command(-s)
to reattach screen
with the command running execute
screen -r
To detach reattached screen press CTRL+A+D
.
Without screen
you should execute your command with nohup
, thus the process will run if the terminal is closed afterwards, like the screen
utility:
nohup your_command(-s) &>/dev/null &
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
Let me give a bit of background to my question. I am using a terminal RSS reader
newsboat
which allows for the usage of macros to operate on links. For example, I have a macro runningcd ~/videos && youtube-dl %u
, which will download a youtube video to~/videos
. However, the output ofyoutube-dl
will be printed in my terminal until the download is complete and for this time I cannot continue usingnewsboat
.I am wondering how I could phrase the command so that it is executed “somewhere else” so that I can immediately continue using the terminal from which it is run.
-
Admin almost 6 yearsWhy the downvote? I know that applications like
youtube-dl
are off-topic, but I think my question is not. -
Admin almost 6 yearsPlease specify: Are you asking about discarding output, or are you asking about job control (e. g. running processes in the background)?
-
Admin almost 5 years@JohnDorian Here is a +1 to compensate that :)
-
-
Admin almost 6 yearsI think I need both discarding output and background here. (Since I am quite a newbie, I couldn't specify the abstract concepts I was looking for, that's why I gave my concrete context.) Thank you for pointing me to the concept of job control, I will certainly read more on this topic!
-
an offer can't refuse over 4 yearswhat does 2>&1 mean?
-
redseven over 4 years2>&1 redirects the stderr (2) to the stdout (1). As the stdout is redirected to a file, it writes the stderr to the same file.