Run a detached process


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Run a detached process
# 1  
Old 05-05-2010
Run a detached process

Hey guys,
Just wondering is there anyway that I would be able to run a detached process that would continue to run regardless of me being logged into the linux host?
# 2  
Old 05-05-2010
To run a detached command you need to redirect all file descriptors so the terminal isn't waiting for them to close. In BASH:
Code:
command > outfile 2> errfile < /dev/null & disown
# you can now log out and have command continue to run
exit

'outfile' and 'errfile' can be /dev/null as well if you don't need to save any output. If you're not using bash, ignore the the 'disown'.
# 3  
Old 05-05-2010
Thanks but the reply I'm recieving is:


bash: outfile: Permission denied
command > outfile 2> errfile < /dev/null
-bash: outfile: Permission denied

again I'm sorry but I'm really noob at this. also what directory should i be making this to? presumably the root?



Quote:
Originally Posted by Corona688
To run a detached command you need to redirect all file descriptors so the terminal isn't waiting for them to close. In BASH:
Code:
command > outfile 2> errfile < /dev/null & disown
# you can now log out and have command continue to run
exit

'outfile' and 'errfile' can be /dev/null as well if you don't need to save any output. If you're not using bash, ignore the the 'disown'.
# 4  
Old 05-05-2010
You dont have permission to open a file in that directory.
# 5  
Old 05-05-2010
Quote:
Originally Posted by killaram
Thanks but the reply I'm recieving is:


bash: outfile: Permission denied
command > outfile 2> errfile < /dev/null
-bash: outfile: Permission denied
It means what it says: You don't have permissions to create 'outfile' or 'errfile' in that directory. What directory are you in?
Quote:
again I'm sorry but I'm really noob at this. also what directory should i be making this to? presumably the root?
What you save where, depends entirely on what you wish to save, where. Smilie But quite probably not into root. If you don't know, try your home directory.

Also, you forgot the '& disown' bit. That's the bit that actually makes it a background process so you can't forget that.
Code:
command > ~/outfile 2> ~/errfile < /dev/null & disown

And remember, if you don't actually need to save any output from this program, you can make all of them /dev/null and it will save nothing nowhere.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run a particular process

Hi I have a perl script where i created 3 nmap scans and the results will output to a text file. But when i run the code the first ip address gets scanned then the others after, but i want to be able to choose which ip address to scan. Here is my code: (`nmap -v -r 99.xxx.xxx -p... (0 Replies)
Discussion started by: kingbp
0 Replies

2. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

3. Solaris

Boot Solaris 10 from detached root mirrors

I recently ran some patching on a Solaris 10 server and as per normal procedure I detached the LVM root disk mirrors first to preserve the pre-patching copy of the OS. During the patching, I ran into some issues which I managed to resolve and completed the patching. However, I was looking around... (5 Replies)
Discussion started by: Grippo
5 Replies

4. Programming

when can we destory thread attributes using pthread_attr_destroy() for detached thrd

Hi All, I am creating detached threads using pthread_create(). As we know, we need to pass the thread attribute structure as an argument to the pthread_Create() API. I want to know what is the good time to destroy this thread attributes using pthread_attr_destroy() call. Also, I want to know... (2 Replies)
Discussion started by: wonderman
2 Replies

5. Programming

detached thread is causing program crash

Hi All, I have scenario where my callback function data_update() can be called anytime. I have written the function data_update() such that it will create detached thread for processing the data sent to this function. data_update() { pthread_attr_t attr_thread; ... (1 Reply)
Discussion started by: wonderman
1 Replies

6. HP-UX

How do i cleanup the removed/detached devices ???

Hi, Am new to HPUX . I need your assistance.. I had attached a Clariion(storage) LUN into HPUX machine, devices with 2GB(c8t0d0) and 1GB(c8t0d1) space. Later some point of time, detached these devices from HPUX machine and executed 'insf' command to build the new devices directory special... (4 Replies)
Discussion started by: raghu265
4 Replies

7. Programming

POSIX - Hot to check if detached thread is still active

Hello, I have created program that run threads one by one, maximum 100. Each thread will process one block of data, and once it`s finished, new thread is created with new block of data....etc I have array of values to control status of each thread, like this: array_thread_status=1... (11 Replies)
Discussion started by: orangem
11 Replies

8. Programming

Can SIGTERM to main process kill the detached threads?

Hi, I am stuck up with a strange problem. I am writing an application - a kinda tracker that reads data from memcache and invokes theads to process each record of the memcache. I dont want to join all my threads because my tracker should poll the cache in regular intervals say sum 300... (2 Replies)
Discussion started by: deepti_v25
2 Replies

9. Solaris

Solaris DiskSuite, boot from detached disk

Hi, I am running Solaris 8 on Sun server with 2 hard drives. I have configured mirroring on the system using DiskSuite tool in order to have the same data on both disks. Now I want to perform some software upgrade and I would like to use the second disk as a backup disk. This means taking this... (3 Replies)
Discussion started by: carlossg
3 Replies

10. UNIX for Dummies Questions & Answers

How can I run a process under particular ID?

I have a script that needs to run under ID say "xyz". the way I do normally is to "su" to the id, enter the password of "xyz" and run the process. However, is there any way run the process under "xyz" without "su" to the ID. A person with root access would be able to run any process under any ID as... (4 Replies)
Discussion started by: ucbus
4 Replies
Login or Register to Ask a Question