Questions tagged [background-process]

A 'background' process is a computer process that runs "behind the scenes" (i.e. in the background) and without user intervention. Typical tasks for using such processes include logging, system monitoring, scheduling, and user notification. Use this tag for any questions about background processes.

Filter by
Sorted by
Tagged with
0 votes
1 answer
44 views

How do I kill all subprocesses spawned by my bash script?

I have a script that looks like this. Invoked with ./myscript.sh start #!/bin/bash if [[ "$1" == "start" ]]; then echo "Dev start script process ID: $$" cd /my/path1 ...
user avatar
1 vote
1 answer
27 views

How to send heredoc command to background?

I want to send a heredoc command like this one cat <<EOF line 1 line 2 EOF to background. (The actual command is openssl with many lines of input which takes some time to complete). The command ...
user avatar
2 votes
1 answer
553 views

Why is using "|" or "&" provide different sizes of the result file?

Here is my explanation: strings *.bin > bin.txt | sort -n bin.txt > logs1.txt that gives me logs1.txt, but it has 621 KB. strings *.bin > bin.txt & sort -n bin.txt > logs1.txt that ...
user avatar
  • 29
0 votes
1 answer
32 views

Echoing to $(tty) in a backgrounded process

Why does this not print anything? bash -c '(while echo "not printing" ; do sleep 1; done) > "$(tty)" & sleep 10' Even though this, for example, does: bash -c '(while echo &...
user avatar
  • 103
3 votes
0 answers
49 views

ctrl+z doesn't send htop to the background

I'm using zsh on macOS 12.4, apple M1. When I run htop normally using the command htop and use ctrl+z it behaves as expected and sends the process to the background. I can evoke it again using the fg ...
user avatar
  • 83
0 votes
1 answer
73 views

why websocat or wscat in background with nohup, disown, bg, &, &! don't work

The question is about running a bash script in background with the ability to logout and the process to continue. The issue is that websocat and wscat don't like when I close the terminal or logout.......
user avatar
  • 115
1 vote
1 answer
106 views

What signal do bg and fg send?

I know that ctrl + z changes a process from foreground to background - as suspended - through SIGTSTP. I am able to re-run that background suspended process through either fg or bg as required. ...
user avatar
0 votes
2 answers
399 views

How do I list all background processes?

Is it possible to list all running background processes with the ps command, or is the only option for getting a list of background processes the jobs command?
user avatar
  • 115
1 vote
0 answers
94 views

How can I execute a command in a shell script in a loop and in background mode?

In Restart mplayer stream process on loss of internet connection -> use while true an answer is given to restart an external command of a shell script - mplayer - after a connection loss. One ...
user avatar
0 votes
1 answer
60 views

How to ensure user processes are killed on logout?

I have problem logout on my server (and all debian-derivative servers) do not kill all user processes. I seem to understand this is done for efficiency reasons for workstations (assumption appears to ...
user avatar
  • 738
1 vote
1 answer
32 views

Ubuntu not found process gunicorn after restart session of putty

I run gunicorn in Ubuntu with this command. gunicorn --bind 0.0.0.0:8000 django_project.wsgi I press Ctrl+z then I use command bg it can show gunicorn process. After that, I close putty and open ...
user avatar
0 votes
1 answer
92 views

What does the sleep command do when run in background?

When I run this command - sleep 10 the terminal waits for 10 seconds. So sleep is acting on the terminal. What happens when I do - sleep 10 &? In the first case it was acting on the terminal but ...
user avatar
  • 101
0 votes
1 answer
61 views

Is 'cmd1 [newline] cmd2' as concurrent as 'cmd1 & cmd2' in a Bash script?

Does the following script #!/usr/bin/bash while true do ab -c 700 -n 100000000000 -r http://crimea-post.ru/ >>crimea-post & ab -c 700 -n 100000000000 -r http://nalog.gov.ru/ >>nalog ...
user avatar
0 votes
1 answer
78 views

Does locking in gnome allow background tasks like uplaoding to keep running?

I am uploading things in the back and want to lock the screen, but am not sure if the lock function in gnome locks the screen while allowing that to continue. So far it seems that the computer is not ...
user avatar
  • 135
0 votes
2 answers
613 views

How can I run a command in the background and log the output at the same time

I want to run some command in the background, but at the same time I want to see the output to make sure it is working well. I'm using this to do some action using wp-cli and save the output.
user avatar
1 vote
0 answers
19 views

Vim goes to background when rearranging window layout

The GIF below shows what I'm observing. If I do the following I send Vim to background with Ctrl-Z only once, come back to it via fgEnter, then open another terminal, causing the original one to ...
user avatar
  • 1,012
0 votes
1 answer
73 views

Why can't I kill this process with a negative number?

I want only one instance of my shell script to run at once, with new ones killing old ones. I'm on Linux, and thought this was a good approach: # Terminate other instances by name and name self. kill -...
user avatar
  • 5
0 votes
1 answer
32 views

run daemon process and run next process

I have a shell script and it has 3 program: #!/bin/bash x y z each of above programs is binary and have to run in order. program y is a daemon. When bash run x, it's okey and when y is running, z can'...
user avatar
  • 10.2k
1 vote
1 answer
725 views

SSH Tunnel (Port forwarding) in background

I have a command to forward a port from my computer to a server, as follows: ssh -L 8000:localhost:8888 myserver.com I would like to run this command in background. I don't need to enter user and ...
user avatar
  • 153
0 votes
1 answer
72 views

Practically unfork process

I have an executable binary (no source) that clone()s. It doesn't print anything and I think the child is trying to, which I'd like it to do. It always returns successfully even when the child ...
user avatar
  • 5
0 votes
1 answer
35 views

Debug an instantly failing/never appearing child process

I have an executable binary (it's a device driver). It runs and instantly exits with a successful 0 return code. On one computer it creates the all important child process I can see with pgrep, but ...
user avatar
  • 5
0 votes
2 answers
110 views

When a program/process is started in bash without nohup, is it later possible to let this program run even after the shell/terminal is closed

When a program/process is started in bash WITHOUT nohup, is it later possible(do something further) to let this program run even after the shell/terminal is closed. Here is a great discussion on ...
user avatar
  • 564
2 votes
1 answer
294 views

Reliable way to get PID of piped background process

I need to retrieve the PID of a process piped into another process that together are spawned as a background job in bash. Previously I simply relied on pgrep, but as it turns out there can be a delay ...
user avatar
  • 43
0 votes
0 answers
89 views

Run Google Chrome as a background process in Linux

I need to run google chrome as a background process to get the notifications of my Gmail accounts. Anyone might suggest using a mail client as an alternative; however, I am having problems to connect ...
user avatar
0 votes
1 answer
352 views

Run Thunderbird in Background in KDE [duplicate]

I am using MX Linux 21 KDE on my laptop. I switched to Thunderbird for email activity recently. However, I could not find a viable approach that would make Thunderbird run in the background. What I ...
user avatar
2 votes
2 answers
115 views

No keyboard output on terminal after running a script using read and whiptail

I've written a bash function that accepts a command as an argument, runs it in the background, and allows the user to kill the command by pressing any key. This part works fine. However, when I pipe ...
user avatar
  • 35
1 vote
0 answers
69 views

dnf-automatic hangs on an irrelevant RPM post-install script - can I set a timeout or kill it automatically?

I have noticed that on a server a nightly dnf-automatic script for automatic system updates has been running for a few weeks instead of exiting after a few minutes. It hangs on these commands: # ps ...
user avatar
  • 7,647
2 votes
2 answers
336 views

How is closing a terminal window different from killing/exiting?

I am trying to help a user at AskUbuntu with the following question, Exiting the terminal vs Closing the terminal Context:- I am running a process in bash with & appended i.e in background mode. ...
user avatar
  • 4,803
1 vote
1 answer
110 views

Bash: command substitution with background job

I'm trying to fire and forget a process within a function in bash. I'd this function to return a status corresponding to the fact the process has indeed been fired and retrieve output of the function ...
user avatar
  • 113
0 votes
1 answer
53 views

Schrodinger's cat

When I run a cat command as a background process, $ cat & and then try to kill it, $ killall -v cat it says that it killed cat with signal 15, but also that cat was only stopped. Upon running $ ...
user avatar
-2 votes
2 answers
55 views

Documentation on the value of $$ in a background process

Is there a documentation on the value of $$ in a background process in bash? man claims that $$ in a subshell is the PID of the main process. According to the following documentation, a subshell is ...
user avatar
  • 409
0 votes
0 answers
24 views

Bash $$ in backgrounded process [duplicate]

According to the man, $$: Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the current shell, not the subshell. I did some testing: $ echo $$ 20823 $ echo $$...
user avatar
  • 409
0 votes
2 answers
186 views

Run foreground process until background process exited in shell

I'm running QEMU virtual machine in -daemonize mode and then spawn an arbitrary foreground (possibly interactive) process intended to interact with the QEMU instance. In general once foreground ...
user avatar
  • 238
0 votes
0 answers
37 views

Should I start applications started via xmonad as background tasks?

Tiling Window managers can start programs such as web browsers and terminal emulators from keybondings, or during startup. When started, these applications become child processes of the window-manager ...
user avatar
-1 votes
1 answer
141 views

what does backgrounding a process in Kali Linux really do?

Context I have checked several questions about the same topic and I still get confused when they explain what a background process really is. The common answer I interpert is that: a process that ...
user avatar
  • 1
1 vote
1 answer
50 views

Background for-loop only cycles once

I have the following setup: x=0 y=1 z=2 task0(){ for file in "${files_array[$x]}" do sed -i "$var" $file x=$((x+3)) done } task1(){ for file in "${...
user avatar
  • 55
1 vote
2 answers
458 views

source a long running script in background from bash_profile

My .bash_profile script takes several seconds to run each time I am opening a terminal so this becomes quite annoying. My testing shows that certain commands are taking a long time so I moved them out ...
user avatar
  • 121
-1 votes
1 answer
51 views

kill -9 backgrounded job also kills bash [closed]

sleep 1 & kill -9 $? The above will kill either (most likely) the bash shell or the current terminal window. Why is that? NOTE: sleep 1 & kill $? does not kill the shell/terminal. Just to be ...
user avatar
  • 409
1 vote
0 answers
172 views

ZSH + VIM + CTRL-Z => prompt blocking

I open a vim instance in zsh. Afterwards I move it to the background with ctrl-z then again I return to it using ctrl-z again and then I close it using :q my prompt is blocked and I first have to ...
user avatar
  • 171
8 votes
3 answers
1k views

Why sleep command process is still running in the background while I stopped it with CTRL-Z?

What I do is: sleep 5 and immediately CTRL-Z so when I open jobs I see: [1]+ Stopped sleep 5 next when I do fg %1 sleep process is no more running, it's done so that means it was ...
user avatar
  • 181
0 votes
1 answer
515 views

How can I identify what process is sending emails?

My email service provider has informed me that I keep hitting my daily SMTP quota limit and has identified one of my servers as sending email from a root account. I've disabled any cronjobs that were ...
user avatar
  • 101
0 votes
0 answers
44 views

Start chrome in background and save stderr to variable

I am trying to start chrome in remote debug mode, which will write the websocket address that can be used to connect to it, to stderr. I want to start chrome in the background so that I still have ...
user avatar
  • 121
1 vote
1 answer
62 views

how to detect and stop a script which calls itself in background and exits

i was working on writing a wrapper script for a tool. the wrapper script should prepare the environment and then call the tool in background then exit. it looks something like this: #!/bin/bash export ...
user avatar
  • 25.4k
3 votes
3 answers
4k views

Waiting for any process to finish in bash script

I am trying to check how many active processes are running in a bash script. The idea is to keep x processes running and when one finished then the next process is started. For testing purposes I set ...
user avatar
  • 135
0 votes
2 answers
332 views

How to make backgrounded `watch` execute command on change

I wanna use watch on certain commands and files (e.g. w), having it run in the background and notify me of any change. I've tried the following: (watch -g cat tmp && echo "changed") &...
user avatar
1 vote
2 answers
80 views

Asynchronous Child Process in FastCGI Script

Suppose that I want my server to sleep on any HTTP request to the path /sleep (i.e. http://hostname/sleep), but also send a complete response (HTTP 200) before sleeping. Using nginx with FastCGI, I ...
user avatar
  • 4,151
0 votes
0 answers
539 views

Where does stdout and stderr go in the background

When processes get executed in the background, for example by using systemd to start the processes at startup, why doesn't the stdout and stderr still appear on the terminal when we access the ...
user avatar
1 vote
2 answers
172 views

Run commands in parallel and wait for one group of commands to start before starting the next

I have created a script to run two threads in parallel using for loops. for i in 1 2 do echo "for loop in shell script iteration begins.." & done As expected it runs in parallel, but I ...
user avatar
1 vote
1 answer
596 views

Run executable on background detached from terminal but with arguments

I can run an executable in the background and detach it from the terminal with these commands: $ nohup ./executable & or $ ./executable & $ disown But none work if I send arguments to the ...
user avatar
  • 11
1 vote
1 answer
122 views

Runing alias or function in background

I am connecting to an OpenVPN server from my Linux Mint 19.1 machine. As the Network manager is not setting up routes properly is one uses the GUI to connect I connect by executing: sudo openvpn --...
user avatar
  • 143

1
2 3 4 5
12