The tag has no wiki summary.

learn more… | top users | synonyms

72
votes
6answers
41k views

How can I close a terminal without killing the command running in it?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in ...
23
votes
4answers
2k views

What's the difference between running a program as a daemon and forking it into background with '&'?

What are the practical differences from a sysadmin point of view when deploying services on a unix based system?
23
votes
4answers
4k views

How to do nothing forever in an elegant way?

I have a program which produces useful information on stdout but also reads from stdin. I want to redirect its standard output to a file without providing anything on standard input. So far, so good: ...
23
votes
2answers
27k views

How to suspend and bring a background process to foreground

I have a process originally running in the foreground. I suspended by Ctrl+Z, and then resume its running in the background by bg <jobid>. I wonder how to suspend a process running in the ...
16
votes
9answers
1k views

How to make sure that a command is not interrupted, even if terminal is closed? [duplicate]

In Linux. Say I want to run a command and it takes too long. I just want to ensure it's done. How?
14
votes
7answers
31k views

Execute remote commands, completely detaching from the ssh connection

I have 2 computers, localpc and remoteserver. I need localpc to execute some commands on remoteserver. One of the things it needs to do is start a backup script that runs for a number of hours. I ...
14
votes
4answers
16k views

How to stop a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to stop its process, then start it again. How can I stop it? I haven't close its shell window. ...
13
votes
2answers
770 views

How to background a command chain?

I want to background a command chain like cp a b && mv b c && rm a. I have tried doing cp a b && mv b c && rm a & but this only backgrounds the last process. How ...
12
votes
3answers
1k views

Wait command usage in Linux?

#!/bin/bash function back() { sleep $1 exit $2 } back $1 $2 & b=$! if `wait $!`;then echo success else echo failure fi bash-3.00# ./back 300 0 failure bash-3.00# ./back 300 1 ...
9
votes
1answer
656 views

Why does “su -c <command> &” seemingly allow a command to run in the background without hanging up

I was helping a colleague who was having problems with a background process intermittently dying. I found out that they were starting the background process by logging in to the server and executing: ...
9
votes
2answers
805 views

Is there any way to let it snow on my linux mint destkop?

I want snow fall on my desktop really badly. Tried Xsnow (with Mate/Marco, Mate/Compiz and KDE/Kwin) but doesn't work. Snow plugin for Compiz doesn't work anymore either. Snow feature of KDE was ...
8
votes
4answers
725 views

I am using `&`: why isn't the process running in the background?

I know that I can append & to a command to run the process in the background. I'm SSH'ing into an Ubuntu 12.04 box and running a python program with $python program.py & -- but when I go to ...
8
votes
3answers
293 views

If you ^Z from a process, it gets “stopped”. How do you switch back in?

I accidentally "stopped" my telnet process. Now I can neither "switch back" into it, nor can I kill it (it won't respond to kill 92929, where 92929 is the processid.) So, my question is, if you have ...
8
votes
3answers
1k views

How do you send command line apps directly to the background?

I already know that pressing ctrl+z stops the app, then I can send the app to background with the bg command, but that means there is a brief preiod of time that the app is stopped. How do I send the ...
8
votes
4answers
346 views

Terminate every background process

I have a few Stopped background processes. kill $(jobs -p) and kill `jobs -p` have no effect kill %1, kill %2, etc. successfully terminate individual processes How can I kill every background ...
7
votes
3answers
234 views

What's the difference between && and ; when forking sleep to background?

I have just asked a question about forking a process to sleep in the backgroud. The notation I came up with myself looks like this: sleep 10 && echo "hello world" & This answer to a ...
6
votes
2answers
1k views

what will ¬ do in bash?

While wanting to start gitg as backgrounded through writing gitg & I accidentally typed gitg ¬. This did not cause an error, instead I got with a later command in the same terminal (translated): ...
6
votes
5answers
2k views

How can I run `watch` as a background job?

When I run: watch 'cmd >> output.txt' & the job gets suspended by the system: 3569 Stopped (tty output) Is there a workaround?
6
votes
3answers
413 views

is there something like a per-user daemon?

I need to run some background processes that live as long as I am logged in with a certain user. Does there exist something like a per-user daemon? I know only of global daemons that live from ...
6
votes
1answer
581 views

Can I make “There are stopped jobs” harder to kill?

Typical scenario: I temporarily need to access a file that my vhost prevents me from accessing. I fire up vim, edit the settings and background vim to tell apache to reload its configuration. ...
6
votes
3answers
2k views

reliable return code of background process

Let's assume the following piece of bash code: foo > logfile 2>&1 & foo_pid=$! while ps -p$foo_pid do ping -c 1 localhost done wait $foo_pid if [[ $? == 0 ]] then echo "foo ...
5
votes
6answers
1k views

Run a command without making me wait

On the CLI, sometimes a command I type takes a while to complete, and sometimes I know when that's about to happen. I'm a bit confused on "backgrounding" and such in Linux. What is the most common ...
5
votes
2answers
3k views

Running piped bash script in background

I'm attempting to build a monitoring script to watch localhost communication using netcat. I have two scripts that I've built, one to start the monitoring loop and one for the loop itself. They are as ...
5
votes
1answer
1k views

background process pipe-input

if i want to display "aaa" on screen: (1)$: echo aaa | cat ... works OK (2)$: echo aaa | ( cat ) ... works OK (3)$: echo aaa | ( cat & ) ... NOT working ...
5
votes
1answer
262 views

How does sh -e interact with &?

I'm using sh (dash) on Ubuntu (lucid) and the manpage has this to say about -e: -e errexit If not interactive, exit immediately if any untested command fails. ...
5
votes
1answer
238 views

Whenever I type some wrong command, my terminal tries to run that command in the background

Something strange started happening to my terminal. Whenever I type some wrong command it tries to run that command in the background. hegeek@colinux: ~# l [9]+ Stopped l thegeek@colinux: ~# ...
5
votes
1answer
209 views

Hard drive writes freezing up Gnome

I'm currently running Debian 6.0.5 on my white Macbook 2008 (4,1) and have recently noticed that when I download, move, or decompress a file, Gnome freezes up completely for at least 20 seconds. These ...
4
votes
2answers
188 views

Opening a file with program in background from shell

The command to launch a program, say evince, from bash shell in background is evince & But what if I want to open some file with evince in background? Nor evince myfile.pdf & neither evince ...
4
votes
2answers
610 views

“nohup sudo …” does not prompt for passwd and does nothing

When I run nohup sudo myscript.sh & I only get something like [1] 1220 in return and do not get prompted for a password. The process does not start either. I want to run this script in the ...
4
votes
2answers
2k views

Shell script wait for background command

I am writing a script, but there is something I need that I can't find a way to do it... I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it ...
4
votes
1answer
551 views

Is there a way to temporarily change the terminal colour?

I use the gnome-terminal and most of my editors with a white on black theme as I find its easier on the eyes. One of my labs requires screenshots of the terminal (with the process) to be submitted ...
4
votes
1answer
1k views

Why do backgrounded processes sometimes stop spontaneously?

Sometimes, some time after I've backgrounded a process with bg in bash, when I press Enter in the same shell to redisplay the prompt (just to check that I'm still in bash when some output from the ...
4
votes
4answers
6k views

Running multiple nohup commands in background

Got two commands cmd1 and cmd2. Of the two, cmd2 takes longer to finish. Need to run cmd2 and then cmd1. Tried to run them in following way: bash$ (nohup ./cmd2>result2 &) && nohup ...
4
votes
0answers
76 views

How do I execute in background / return early?

For reference, I'm using phpseclib to control a remote SSH server using the 'root' account. I have to start/stop a java process which is ran in the background. Stopping works fine with killall java ...
3
votes
2answers
689 views

Bash script needed to run every second

I have a few cleanup commands to run for my datacaching scheme. I was thinking a bash script would be an easy way to check if the full clean up job needed to be run. But the cache is very time ...
3
votes
2answers
661 views

How to reload a background process?

I have a python script which I would like to run in the background. So I do this: $ nohup python script.py & If I am frequently making changes to the script, I need to terminate the process ...
3
votes
3answers
721 views

Permanent background ssh connection to create reverse tunnel: what is correct way?

Related question: initiate ssh connection from server to client Answer from there helped me a lot, this command does what I need: ssh -R 2225:localhost:22 loginOfServerWithPublicIP@publicIP So I ...
3
votes
2answers
512 views

What is “Exit 2” from finished background job status?

I have an exercise to put in a file some data (*conf from some directories) and need to do this in background. I did it and I am wondering what is the meaning of output messages: [A@localhost tests]$ ...
3
votes
2answers
66 views

What environment and credential is used by startup, background and service processes

Startup scripts (on boot) Processes running in (or sent to) the background (when using SSH -fN for example) Services etc... What $path variable will they be using? What credentials? Anything else I ...
3
votes
1answer
3k views

How to recover a backgrounded job from a previous shell? [duplicate]

Possible Duplicate: How can I disown a running process and associate it to a new screen shell? I launched a command that lasts a long time. I had to disconnect so I moved it in the ...
3
votes
3answers
730 views

Monitoring progress/liveness of background jobs

I have started a background job. Is there a way to know how it is progressing, and whether it has stopped? My command line is like: java weka.classifiers.trees.J48 -t data.arff J48-data.model ...
3
votes
1answer
33 views

Is there an easy way to background a sudo shell?

A bit more details, what I'm looking for is some kind of ^Z for sudo shells. For instance when running a long command I can hit ^Z to suspend the command or when I do ~^Z in ssh after hitting Enter. ...
3
votes
1answer
4k views

bash: Run command in background and capture pid [duplicate]

Am writing a bash 4.1 script... Would like run another script (or internal function) in the background... And capture the pid of that background job in a variable in the foreground script... If the ...
3
votes
2answers
962 views

Dynamically change desktop background from bash script

Is it possible to change the GNOME desktop background during some period of time by just a random phrase from the list on black screen? Will is seriously load the CPU and consume battery life?
3
votes
3answers
116 views

Log to multiple files while process in background (nohoup)

I have bash script that logs to two log files in parallel. echo "$(date) | [STATE] Activating IP forwarding" >> $logsPath$logFileName echo $(date +"%Y-%m-%d %H:%M")","$previousState >> ...
3
votes
1answer
510 views

ssh “-f” don't give back hand in bash when listening to stdout/stderr

Please look at these: ## Does NOT return to the shell, but Ctrl-C can exit ssh -S none -fNR 13018:localhost:22 example.com | cat ## Returns to the shell (no "-S none") ssh -fNR ...
3
votes
0answers
77 views

any way to un-disown / re-attach an interactive process to the tty? [duplicate]

Possible Duplicate: How can I disown a running process and associate it to a new screen shell? In bash is there an opposite of disown, that is, to re-attach a process I've accidentally ...
2
votes
5answers
2k views

How to start a program in the background

The program Boblight does not run in background. There is no noticeable difference between executing sudo boblightd and sudo boblightd& How can I solve this problem that the console will ...
2
votes
1answer
410 views

Is it possible to customise the prompt to show the if there are any background jobs?

Is it possible to customise the bash prompt to show the if there are any background jobs? I find it easy to forget that there are background jobs. Say if the prompt was... $ Is there a way to ...
2
votes
3answers
2k views

How to send to background a running process started with sudo?

I have just installed SLC6 (derived from SL6 derived from RHEL6). I can send a running process to the background by hitting Ctrl-Z in the terminal where it was started. However, I can't do it when I ...