Stack Exchange Network

Stack Exchange network consists of 175 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.

1
vote
1answer
12 views

Killing two-part process with && by PID

I have a bash script where I am sleeping and then executing a command in a background process. For example sleep 30s && ./script.sh & If I grep ps for "sleep 30s" and kill the process ...
1
vote
0answers
41 views

How to know end of background process

I have a script running in background ./test.sh & How can I know the completion of test.sh. I have to check the process id from an another console. Is there any another way
0
votes
1answer
35 views

Are processes within screen treated differently from foreground processes?

Assume I have a long running process, long_running_proc with a single TCP connection to host host.example.com. Is that process treated differently, by the OS or the shell, when it's run as a ...
1
vote
1answer
55 views

Is there any difference to run a process in the background with an & vs when it has --daemonize option?

Some program has --daemonize option to run itself in background, e.g. php-fpm. I was wondering is there any difference between using --daemonize or just use the old & way to run the process in ...
-1
votes
1answer
89 views

Why does the process ID change in the output of “ps -l”?

Whenever I run a command in the terminal on Linux, at runtime, its PID changes. The command I used after running one program two times at runtime, was ps -l. Why does the program change process ID?
0
votes
0answers
44 views

How to execute unix command after few background jobs?

My c-shell code has to complete few concurrent background jobs before execution of some unix commands. However, somehow in code my background jobs never returns handle to unix commands. i.e. $cmd1 | ...
1
vote
0answers
35 views

Log python http server output to file

I want to start a python webserver in the background and log all of its output to file. Instead the the servers output appears in the terminal. Even tho i guess this is pretty basic ... I've got no ...
6
votes
4answers
383 views

Run command in background with foreground terminal access

I am trying to create a function that can run an arbitrary command, interact with the child process (specifics omitted), and then wait for it to exit. If successful, typing run <command> will ...
0
votes
0answers
36 views

How to get PIDs connected to another PID's standard input/output/error?

After something like first_command | … | last_command & $! is set to the PID of last_command. How can I find the other PIDs in this pipeline? Especially, is there a convenient way to find the PID ...
1
vote
1answer
31 views

Can't run a background process and other command from bash in one line: unxepected token `;' [duplicate]

I have a program that receives an argument and prints it every second: ~# ./myapp 234 234 234 234 234 ... I want to be able to run it in the background and right after a shell but it must be in ...
0
votes
0answers
27 views

Background processes in bash preserving order

From a GUI terminal emulator running bash, I would like to open a tabbed instance, get its X window ID, and use it to embed four st terminal instances inside tabbed, with titles from 1 to 4, in ...
1
vote
1answer
47 views

Signal trap from background job without pressing enter

In Bash 5 I ran into a situation where I want to do the following: trap 'echo trapped!' USR1 while true; do kill -SIGUSR1 $$; sleep 1; done & But I have to press enter on keyboard every time the ...
0
votes
1answer
46 views

process running in background but still I cannot use the command line

I suspend a running process by ctrl+Z and the bg to place process in the background but the process still running in the foreground so I cannot use the command line. How can I put the process ...
1
vote
1answer
33 views

How to get variables expanded in output of jobs command

As you can see in the following output the variable $i in the output of ps aux is expanded to sleep 1, sleep 2, etc. Is there a way to make zsh do the same? In the jobs output all the commands get the ...
0
votes
0answers
18 views

Question on Netstat output “app --node-in” & other

While doing "netstat -p", I got result out of which, I am unable to understand below output:- unix 3 [ ] STREAM CONNECTED 3889891 23976/app --node-in unix 3 [ ] STREAM CONNECTED 33223 ...
0
votes
0answers
24 views

Error when run multiple commands in one line in bash [duplicate]

I have a program named "mem" and it takes one arg. If I run it by ./mem 1, all things went well. But when I tried to run "mem" multiple times with different args like this: ./mem 1 & ; ./mem 2 &...
0
votes
0answers
43 views

Why does my infinite shell script occasionally stop?

I wrote a python script that I want to keep running indefinitely. Most of the time it sleeps, but every once in a while it has to come to life to do some operations. I need to keep it running on an ...
1
vote
1answer
128 views

Bash - Execute background process whilst reading output

I'm trying to start a process (target_executable) and have it run in the background. I know I could do that via ./target_executable & but in the bash script that's running the show, I want to read ...
3
votes
2answers
194 views

How to quit command prompt after a sleeping command executes?

I have a simple script: f=1 # initial value loop(){ ... if [[ $f -eq 1 ]] then echo $msg1 f=2 (sleep $interval; loop) & exit 1 elif [[ $f -eq 2 ]] ...
0
votes
1answer
64 views

How to avoid zombie process while working with named pipe?

We normally do the writing job to a FIFO file in background using a control operator &. Something like below. if [ ! -p "/tmp/mysqld.init" ]; then mkfifo /tmp/mysqld.init fi echo "something"...
2
votes
0answers
36 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
51 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
1k 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
651 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
55 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}' :...
3
votes
1answer
74 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
34 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
59 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
108 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
61 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
162 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
76 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
211 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
120 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
2answers
48 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
98 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
246 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
90 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
444 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
36 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 &...
1
vote
1answer
182 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
37 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 ...
1
vote
1answer
62 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
357 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
45 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
377 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
144 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" >...
0
votes
2answers
106 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
195 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
53 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. ...