Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
0answers
24 views

How to trigger a command after named pipe closes?

How can I execute some command after the named pipe has been readout in other end. I was trying to use trap. But nothing happens. My script is something like below. #!/bin/sh cleanup() { echo "...
1
vote
2answers
42 views

Everything should be run in background instead of waiting

I have written a script that takes commands from user and runs through a huge list of servers and writes to a single file. Once writing has completed it triggers an email. My requirement is: the ...
8
votes
3answers
947 views

Why can't I see the “wget” job when I execute it in the background?

I use wget command in the background like this wget -bq and it prints Continuing in background, pid 31754. But when I type the command jobs, I don't see my job(although the downloading is not ...
9
votes
3answers
601 views

“Variabilize” the ampersand (background a process)

I want to know if there's a way to put the ampersand in a variable and still use it to send a process to the background. This works: BCKGRND=yes if [ "$BCKGRND" = "yes" ]; then sleep 5 & ...
0
votes
0answers
24 views

How to run vlc stream in background on raspbian?

I'm having trouble launching a command line in background. The command I'm trying tu run in background is : raspivid -o - -t 0 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/cam}' :...
2
votes
1answer
55 views

Does ` (sleep 123 &)` remove the process group from bash's job control?

Does the following way $ (sleep 123 &) $ jobs $ remove the process group of sleep 123 from bash's job control? What is the difference between the above way and disown then? Note that the sleep ...
0
votes
0answers
32 views

Use 'ssh ps aux' to gurantee process alive, mistake sometime

Q1 : Recently, some operations scripts is deployed on machine-01, in order to monitor process alive in remote machines. This feature is done by periodly do following cmd: ssh $ip "ps aux | grep $...
0
votes
0answers
58 views

Time Machine analog for Linux

On my Apple Mac I use TimeMachine to save backups. This is effortless and quite reliable and provides access to time-stamped historical files going back years. It is also efficient (the backups ...
2
votes
1answer
61 views

Do the Firefox children processes correspond to number of tabs?

I am running Firefox Quantum 63.0.3 (32-bit) on Ubuntu. In output of htop command (sorted by Command name) I see the following I see 6 children process below the original firefox process. What do ...
2
votes
0answers
58 views

Why can't I send a post request to my server after SSH logout?

I've created a .jar file which listens on port 8089 and receives post requests. I start it in the background on my linux machine with the following commands: nohup java -jar myServer.jar & [1] ...
5
votes
2answers
137 views

Process killed before being launched in background

I'm using a bash script script.sh containing a command cmd, launched in background: #!/bin/bash … cmd & … If I open a terminal emulator and run script.sh, cmd is properly executed in background, ...
0
votes
1answer
32 views

How to background a process when tmux prefix is z?

Usually I would background the foreground process using ctrl-z, but when running in tmux with the prefix key bound to z, then obviously ctrl-z just invokes tmux. Likewise if I try to escape the ctrl-z ...
1
vote
1answer
79 views

launch reverse tunnel with autossh on bootup in Ubuntu

I would like to launch a ssh reverse tunnel on system launch. The following line let's me establish the tunnel fine - but I end up being logged into server which I don't want, especially not from an ...
0
votes
2answers
50 views

How would you put a job which requires sudo to background?

I am looking for a way of putting a job which requires sudo to background, with as little interaction as possible except maybe typing my password. sudo requires password from terminal, while ...
0
votes
0answers
15 views

How do you make HAProxy Service run under HAProxy account after manual install?

Running CentOS 7 here. Since yum repository had a very old version of HAproxy, I decided to follow these instructions for a manual compiled installation. But when I do a grep for HAProxy with ps -...
0
votes
2answers
46 views

Run two dependent commands in background

I need to execute two commands in the background function "$arg1" "$agr2" arg3 && declare "workspaces=$arg3" first it will execute function if it complete then it will initialize arg3 in ...
0
votes
1answer
51 views

Automatically restarting a process when it dies?

I have a process running on a raspberry pi. After ssh ing into in to the process is started like this: nohup .../blah/blah & IIUC this allows me to log out of the pi and the process keeps ...
1
vote
2answers
105 views

Difference Between bg and kill -CONT

I was running an application in the foreground, and put it in the background by hitting CTRL+Z (and stopped). To get it back running, I ran the command bg %1 (which is its JOBSPEC). I thought why not ...
1
vote
1answer
60 views

find command of nobody runs on every fresh boot in the morning - debian stretch

Folks, find executed by nobody runs automatically on every fresh boot (in the morning when I boot the system). I guess it is to do with updatedb. How can I confirm my assumption and stop this from ...
4
votes
2answers
322 views

How to suppress stdout / stderr from a shell script output?

I have a script that is suppose to stop and recover the process to run in the background: process_id=`ps -eaf | grep -i daemon | grep -v grep | grep -v status | grep -v stop | awk '{print $2}'` (kill ...
1
vote
1answer
32 views

How to produce from the terminal in a single command 2 emacs windows?

I am trying to open 2 separate windows/instances of emacs from the terminal in a single command. I have tried: emacs &; emacs & (error: bash:syntax error near unexpected token ; and emacs &...
0
votes
0answers
49 views

Watch multiple bash commands with dynamic output

I'm doing multiple downloads at the same time with wget, as this: while IFS= read _addr; do coproc wget "http://<host>/<subdir>/$_addr" done < <(cat filelist.txt) coproc puts ...
1
vote
1answer
94 views

Daemon vs worker and when to use what?

(Note that, below, I am frequently using term "daemon or worker" just to indicate that I dont know which word to use as I dont know the exact difference between them in the context explained below.) ...
1
vote
0answers
35 views

Is there a way to run a program at startup and in the background without root access?

I'm trying to have it so that my program is able to run at startup and in the background without having the user to be root. Ideally this would happen at the installation of the program and not using ...
0
votes
1answer
38 views

Killing background processes started in nix-shell

I am developing a simple data science environment with Python tools and a database. When I enter the nix-shell, I spin up the database process. I would like to spin it down when exiting the ...
0
votes
1answer
253 views

How to run multiple command in one line and some commands in background at the same time?

I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is ...
-2
votes
1answer
36 views

Pipe output of two programs running in parallel to another program [duplicate]

I have two programs foo.sh and bar.sh both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third ...
2
votes
2answers
220 views

run another process after the background process is complete

said i have looping script in file test.sh, i just want to running script "running_script2.sh" after the background process is complete, what i try like this, but it's not working . for id in 1 2 3 ...
1
vote
2answers
80 views

Background process of subshell strange behaviour

I wonder why some similar bash commands behave the way they do. I have a bash script foo: #!/usr/bin/env bash while true do echo "reading" read data echo $data echo "stderr msg" >...
-1
votes
2answers
63 views

Background process (postgresql) receiving SIGINT from Ctrl-C in shell

I wrote a shell.nix file to build the development environment for one of my projects. I'm using a shellHook to ensure a postgresql server is started when you drop into the nix-shell. The shellHook is ...
0
votes
1answer
158 views

Running multiple scripts in background and returning immediately

I have this bash setup configured to run in tandem with a Wifi manager, which provides events like HOTSPOT, CONNECTING, CONNECTED I want to run scripts based on events and return immediately, not ...
0
votes
1answer
47 views

How can I periodically record the dir stack and jobs of a shell without occupying the shell?

I have a script $ cat my.sh #! /bin/bash - dirs -l > /tmp/test/dirs_record jobs > /tmp/test/jobs_record So when I source ./my.sh, it will output the dir stack and jobs in the invoking shell. ...
-1
votes
1answer
32 views

Run a command in the background, wait for a particular log line, then run a new command in the foreground

I'm looking to run some SQL statements into a mssql database before the DB is started (this is happening as part of a docker RUN step). From what I can tell, the only way to do this is to start the ...
0
votes
0answers
86 views

remote process run through ssh gets killed if UI is closed

I have written a script which essentially does 2 things: Runs a UI for listening to the actual program running on the server remotely run the program on the server All goes well, the UI starts, then ...
0
votes
2answers
42 views

PID of the background function, F, in commands invoked in subshells inside F

When foo is run in the background, the BASHPID of foo (bashpid_of_foo) is not available inside the bodies bar_1 to bar_n via $BASHPID, since they get invoked via the Command Substitution feature of ...
7
votes
3answers
919 views

How to analyze this command `{ 2>&3 “$@”& } 3>&2 2>/dev/null`?

A few weeks ago, I have seen a weird answer about the question "(How to) silently start task(s) in the background?". This solution seems incorrect (c.f. my answer) although the shell seems to start ...
0
votes
2answers
103 views

how to wait in background?

I have two background jobs with job id 1 and 2. I want to do something when job 1 is done, but I don't want to hang. Currently what I get is wait 1 && do whatever, but this command it self ...
1
vote
1answer
73 views

How can I guard a Docker container so that it's always running?

I have a HBase Docker container that's running on several developers laptops. When the developers close their laptops, the Docker container will invariably die and stop running. This is how we're ...
2
votes
1answer
2k views

Testing an infinite loop in the background within Docker?

I want to run a background queue working in my docker image: php artisan queue:work --daemon --sleep=1 --tries=3 & Immediately after that it starts Apache httpd running a PHP laravel app. The ...
2
votes
1answer
38 views

Multiple instance of same program, obtaining output

I have a shell program in Ubuntu 16.04, named foo, that outputs status update when I press any button. It's located in /usr/local/bin/foo, so I can call the program anywhere. The program works like ...
3
votes
1answer
427 views

How can I test if a background job failed before it exits?

I'm writing a script that launches a virtual framebuffer with Xvfb. I want to make sure the command succeeds, but I don't want the script to wait until the command completes, because Xvfb continues ...
0
votes
0answers
51 views

Why does nohup command interrupt?

I put a command in .bash_profile file. The command is: nohup stdbuf -oL -eL sysdig -c spy_users 1>>/path/to/out 2>>/path/to/err & While I am working on terminal it appears: [1]+ ...
1
vote
1answer
85 views

Does ampersand also function as line terminator? [duplicate]

I know that in bash, the & symbol delegates a command to the background, but is it also supposed to double as a special line terminator? To give an example of what I'm referring to, I found this ...
0
votes
1answer
158 views

How to exit a process after disown

I use disown to run long-running process via SSH. For example I run the following program: vmd -e script.tcl > out.txt & Then I use disown -a to deattach it from the shell. When I reconnect ...
2
votes
4answers
122 views

Controlling a background process

I'm looking for a way to start playing an audio file (mp3, m4a) as a background task from a shell, and then be able to do things like pause/fast forward at a later time. Is this possible either using ...
-1
votes
1answer
41 views

How do start a background sudo task on startup (like a daemon)?

I am familiar with controlling preconfigured system daemons (as packaged by Debian) with the systemctl command. I also have a custom "service" that I start manually with: sudo process --option ...
9
votes
1answer
2k views

Why nohup background process is getting killed?

I tried starting a shell script via a remote session, which starts a process in the background using the command. nohup python3 run.py > nohup.out & When the remote session is closed, the ...
4
votes
1answer
95 views

Why is bash 'not always' showing the 'Terminated' message after killing a process? [duplicate]

Why does this difference matter? The two blocks in the code below differ by the last line: #!/bin/bash if [[ -n "$1" ]]; then sleep 1 & p=$! kill $p &> /dev/null else sleep ...
2
votes
2answers
71 views

Can I pipe output from a started process? [duplicate]

Say I've started program and it continues writing some output to stdout. Is there some way to add a pipe so that I can, for example, count the number of lines it has produced with wc -l?
13
votes
1answer
755 views

When were background processes invented?

Looking for both a date and authoritative reference. Expected answer sometime in the 1960's. This information is essential for writing an impactful feature request.