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.

4
votes
1answer
968 views

Launch background process from sh and close the terminal

How can this be achieved in sh (not bash!)? nohup sh -c 'helper-bcpy.sh "$0" "$1" "$2" "$3"' "$num" "$full_path" "$log" "$log_finished" >/dev/null & I would have expected it to send the ...
2
votes
1answer
401 views

Safely kill foreground process when a background process ends

There are two scripts, the first in the background, the second in the foreground: trap "ret=\$?; rm -f pipe1 pipe2; exit \$ret" EXIT INT TERM QUIT my.bin > pipe1 < pipe2 & my-term.sh pipe1 ...
2
votes
1answer
158 views

How to get the executed command of a process which has completed successfully using the PID?

I have small script, abc.ksh that takes 3 parameter e.g abc.ksh ${a} ${b} ${c} I will read from a config file with 'n' no of entires and I will execute abc.ksh 'n' times in parallel using a for loop. ...
2
votes
1answer
1k views

SSH fork kills connection

I am using a Linux script which has the task of forwarding control of the system to remote support. In this script one of the commands is a ssh port forward command that will forward the port of the ...
1
vote
1answer
54 views

mouse-pointer symbol “background activity”

I´ve got a question concerning my mouse-pointer. From time to time my mouse-pointer changes to a symbol that represents something like an arrow melted together with a loading-circle. I tried to find ...
1
vote
1answer
48 views

Parrallel ongoing for each file loop?

I want to continuously monitor some log files. What I have below works if I switch the tail -F for cat $log_file. When I use -tail -F the first log file works but because its process doesn't finish it ...
1
vote
1answer
52 views

How to run process for user when he logs in and terminate when his last session is closing?

I'd like to start a specific process for specific user when he opens his first session and terminate the process when user closes his last session. No mater how many user sessions are active, there ...
1
vote
1answer
457 views

What can run in the background on linux?

Specifically, do function calls in a bash script run in the background if called with &? I was trying to come up with a solution to Change a bunch of owners on files and thought something like ...
1
vote
1answer
840 views

how to get the timeout exit code while run a command in background?

I'm writing a shell script to run ping command in background, and in the same time, set a timeout value for ping command, I want to get the exit code if the ping is ended by timeout, I use below: ...
1
vote
1answer
70 views

execute a c prog in background through shell script

I want to run a c prog in background using shell script and once the prog starts running in background my shell script should continue to run without waiting for the c prog to end. I am using ...
1
vote
1answer
946 views

Job Control: How to save output of background job in a variable

Using Bash in OSX. My script has these 2 lines: nfiles=$(rsync -auvh --stats --delete --progress --log-file="$SourceRoot/""CopyLog1.txt" "$SourceTx" "$Dest1Tx" | tee /dev/stderr | awk '/files ...
1
vote
1answer
445 views

How can I run unattended processes as authenticated AD/LDAP users?

I'm switching some servers over to Debian 8 and using realmd for Active Directory (LDAP/Kerberos) authentication. This has been working great and allows Domain Users to login to my server, etc. ...
0
votes
1answer
24 views

How to start my application after starting of “daemon” process in single script

I have a script, that starts my server. I want to start openvpn client before it. Here my current working solution: #!/bin/sh openvpn --client --config $OVPN_CONFIG & sleep 10 npm start I ...
0
votes
1answer
106 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"...
0
votes
1answer
211 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
25 views

Ctrl-C'ed a process but it kept running, don't see it running in the background

I Ctrl-C'ed a build job I was running in my bash shell. It continued to run in the background and print output to the stdout, however according to jobs -l no background job was running. Do we know ...
0
votes
1answer
403 views

postgres processes running while not using it

as in the object of the discussion thread I have the following situation: all time I start my linux OS, I check processes running with the top command in bash and I always find 7-8 postgres processes ...
0
votes
1answer
89 views

Access foreground data from background process

I want to run a process in the background, using &, and have the process access the data used in the foreground process. Here is an example: A() { echo "$a" } a="abc" while true; do echo "$(A)"...
3
votes
0answers
53 views

Identify process

Every couple of minutes my Mac OSX machine starts running a process that consumes 10% of the CPU. It runs for a couple of seconds and then stops. I can see the process coming up in 'Top', but the name ...
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 "...
2
votes
0answers
62 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] ...
2
votes
0answers
31 views

Log background jobs started in all the manually started shells?

Sometimes I accidentally killed all the background jobs in a shell, for example, because The window of a Window's program running under Wine is not in the front by default. I know I can use ...
2
votes
0answers
315 views

Background task in bash script

I'm trying to write a "while true" bash script that responds to events. (It's a webhook for git push notifications, but that's not very relevant at this point.) I could block, waiting for the next ...
2
votes
0answers
28 views

How can I make sublime appear in the jobs list?

How can I make Sublime Text appear in the jobs list when started from the command line? For example... $ subl $ jobs ... doesn't show anything. I want to do this because my prompt is configured to ...
2
votes
0answers
332 views

Open a program (VLC) and move it to the foreground

On a Mac, specifically, when I use the VLC command line to open a video file, it opens in the background by default. How can I instead move it to the foreground whenever I run the command to open a ...
2
votes
0answers
1k views

What happens when you background a function which calls another function?

I'm trying to find out how to background a process in a script that calls another function and reliably terminate it when ready. Will I have to move it all into one function? function dosomething { ...
1
vote
0answers
50 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
1
vote
0answers
115 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 ...
1
vote
0answers
38 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
0answers
34 views

Can't execute KDE Dolphin from web-based PHP Script - but works for all other X programs

In a PHP script running under nginx/php-fpm, I can execute any X program using this PHP code: shell_exec("DISPLAY=:0 /usr/bin/nohup '{$command}' > /dev/null 2>&1 &"); This will open ...
1
vote
0answers
353 views

What is the difference between the SIGHUP generated by typing “exit” in the SSH shell terminal vs clicking the “X” button in the PuTTY window?

Referring to this question, I am trying to use nohup <command> <arg> & to continue to run a command in the background after I logout from the SSH shell terminal. However, the ...
1
vote
0answers
801 views

How to understand the output of tracing running an external command in background via strace

In Ubuntu, I run date & in an interactive bash shell whose pid is 6913, and at the same time, trace the bash shell from another interactive bash shell by strace. The output of tracing the first ...
1
vote
0answers
707 views

nohup is not working when called from root folder

When I execute the nohup command from the same folder it's working fine (server.php is used to listen to a port 7070) root@servername:/var/www/html/admin# nohup php server.php & [4] 2803 root@...
0
votes
0answers
48 views

Run script in background using `&` or `()&`?

If I want to run a script in background, for example a.sh, should I run ./a.sh & or should I put it in a subshell then background it? (./a.sh) & I test both and don't see difference, both ...
0
votes
0answers
49 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 | ...
0
votes
0answers
45 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 ...
0
votes
0answers
32 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 ...
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
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 ...
0
votes
0answers
70 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}' :...
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
60 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 ...
0
votes
0answers
150 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
0answers
73 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]+ ...
0
votes
0answers
68 views

how to redirect to file and fork in background

i have bash script which running in cron which is outputting to file. however in my script I am running another command which is meant to output to file but is not outputting to file. bash /opt/SP/...
0
votes
0answers
103 views

Bash Process Substitution Hangs When Listing Bindings

TLDR: cat <(INPUTRC=/dev/null bash -c 'bind -pm emacs') # freezes # I can't use this because I need to pipe the output of the bind cat <(INPUTRC=/dev/null bash -c 'bind -pm emacs' &) # ...
0
votes
0answers
50 views

Starting another program that shares output terminal with current program?

I have a matlab script that I run from the terminal, that script creates an instance of another program using: system('cd <path> && mpiexec -n 1 ./<program2> &') Problem is I ...
0
votes
0answers
228 views

Compare running a command directly and in background

In Ubuntu, I run date in an interactive bash shell whose pid is 6913, and at the same time, trace the bash shell from another interactive bash shell by strace. By using tracing, I would like to ...
0
votes
0answers
207 views

Ways to make a process survive its parent shell's exiting?

In order for a process to survive its parent shell's exiting, what necessary and sufficient conditions does the process need to meet? Specifically considering signals, what signals should be ...
0
votes
0answers
98 views

How to make a background service to capture commands and their output?

Is there anyway to make a background service capture all the commands executed by a user and also save the output in a text file?