View Full Version : Is it possible to Run a process in background?

5th April 2007, 02:02 PM
Hello all,
I'm fairly new in this field; guess I could consider myself a rookie. Anyway, I just wanted to know if you can run a process in the background.

Example: I use rsync to backup approx 1.2 Tb of data and take a very long time. There are times that the work day as come to an end and the backup is still running. Can I log in to a server issues a command (like a backup job) and let it run in the background even I log off at the end of the day? Also is their a way I can monitor the current job running when I decide to log back in and check if all is going well?

Using Fedora Core 6

Thanks in advance.

5th April 2007, 02:15 PM
nohup rsync ..... &

nohup forces rsync to ignore the SIGHUP signal (sent when you logout) and the ampersand at the end sends the rsync process into the background. The ..... is your rsync options.

5th April 2007, 02:19 PM
Thanks for the quick reply moosetooth,
I'll try that, I'll let you know if it works out for me.

Thanks again

After issuing the nohup rsync -vWa -e ssh --delete ......... &

I got: nohup: appending output to `nohup.out'

Is this normal? Please explain.

5th April 2007, 03:35 PM
Yep, that's normal. If nohup.out can't be written to the current directory, then it gets put in your home directory.

Not sure if you already know this, but another useful thing to use with long-running processes started from the command-line is CTRL-z and bg. It's a way of switching an app running in the foreground to run in the background. Say you run some program from a terminal but do not put it in the background with the ampersand (&) symbol at the end of the command. If you wanted to do other stuff from that terminal while that application runs, you don't have to restart that app or open a new terminal. You could just do a CTRL-z from the current terminal. That will temporarily suspend the app that's running and restore control back to your terminal prompt, so you could then do a 'bg %n', where n is the number returned in brackets when you did the CTRL-z. That will now run the app in the background.

Here's an example:

$ nedit

[1]+ Stopped nedit
$ bg %1
[1]+ nedit &

That blank line right after the initial command is where I did the CTRL-z from the terminal, and I ran 'bg %1' because 1 was the number in brackets ([1]+ ...).

5th April 2007, 04:18 PM
I got: nohup: appending output to `nohup.out'
Is this normal? Please explain.

nohup.out is a text file containing the output of the program (in this case rsync) it is running that would normally be written to the screen.