Running commands in backgroud


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running commands in backgroud
# 1  
Old 03-26-2013
Running commands in backgroud

I have a small question may be this will be discussed before

I have two files file1 and file2 with huge data and I am running the commands as

cat file1 |sort &
cat file2 |sort &

If the session is got disconnected or logout will this command run in background,
or shall we use nohup
# 2  
Old 03-26-2013
Get rid of the cats and use nohup:
Code:
nohup sort -o sorted1 file1&
nohup sort -o sorted2 file2&

# 3  
Old 03-26-2013
I just need to know this command will run in background if the session got disconnected.
# 4  
Old 03-26-2013
Yes, if you use nohup, it will continue to run in background if session is disconnected. That's the whole point of nohup.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running two commands in background

Hi I want to run two commands in background, i am using below way, but it is not working, i m calling these two commands from one script to another server where below commands are running, in my script ssh is working fine, but command is not going in background, please advise what should i do. ... (10 Replies)
Discussion started by: learnbash
10 Replies

2. UNIX for Dummies Questions & Answers

Echo out running commands

Is there any way in a script to print out the commands being ran? In DOS script, there is the "@echo on" and "@echo off". so I have a script like this: #!/bin/ksh echo "hello there. moving files." <turn on echoing here> cp thisfile.txt thatfile.txt cp whatfile.prop whyfile.prop <turn... (2 Replies)
Discussion started by: ronron5477
2 Replies

3. UNIX for Dummies Questions & Answers

Running two commands in one line

hi! how do i run 2 command from the same line e.g: 'which screen' and then ls -la 'which screen' (4 Replies)
Discussion started by: rdns
4 Replies

4. Programming

Running shell commands from C/C++

Hi guys, I know using system() we can run unix commands but the problem is, I can't get any returns with the system(). I am returning stuff from my shell scripts that I need to be able to read from my C code. Anybody has cure to this problem? :)) Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

5. Shell Programming and Scripting

multiple child scripts running in backgroud, how to use grep on the parent?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (5 Replies)
Discussion started by: albertashish
5 Replies

6. Shell Programming and Scripting

piping and backgroud processes (daemons)

Hello to all, I've a strage problem here: a perl script that parses the output of sar -q 300 0 (one line of performace data each 5 min. infinately) works fine from the CLI. It processes one line output every 5 minutes. If i disconnect it from the terminal (executing it with cron, nohup startporc... (2 Replies)
Discussion started by: demwz
2 Replies

7. Programming

Running UNIX Commands from C

Hi, -How can I get number of files, cpu usage (percentage), memory usage, disk usage, ...etc, using C program ... I can use unix command ( system(command) )but I want the value to be returned back to my C program to use it in my code? How can I do that? Thanks in advance ... (2 Replies)
Discussion started by: zainab
2 Replies

8. Shell Programming and Scripting

running commands from outside of bash

Hello all! I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this? Anyone can do something for my query? Click here if you can't understand my query or to know the need for this query. (3 Replies)
Discussion started by: rakabarp
3 Replies

9. Shell Programming and Scripting

How to disable running commands from vi

Hello, We have a requirement to disable running shell commands via vi using "!". Can anybody please suggest how to disable this option. The requirement arises because we open up a xterm window with a config file in vi mode for the customer to edit. After the customer edits the config... (1 Reply)
Discussion started by: Umesh_Sharoff
1 Replies

10. UNIX for Advanced & Expert Users

backgroud process

Hi experts How to write a shell program(sh) that running on the backgroud when foreground processing something, such as prompt ....... till the background process finished. thx (4 Replies)
Discussion started by: trynew
4 Replies
Login or Register to Ask a Question