LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2004, 01:29 AM   #1
skguha
LQ Newbie
 
Registered: Mar 2004
Posts: 21

Rep: Reputation: 15
Running script in background


Hi,

I have written a script called run. What it does is it executes a C program and stores the result in a text file (appends to it) . This process goes on because i have to log the data. I was wondering if there is anyway i can run the script in the background cos once i type

./run

at the command prompt, i dun get back to the prompt again as the script keeps on running. I need to go back to the prompt. How do i manage this ?? I am relatively new to Linux.
 
Old 04-02-2004, 01:43 AM   #2
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
type this:

./run &

the & char will make it run in background

greetz,
-= iluvatar =-
 
Old 04-02-2004, 02:13 AM   #3
skguha
LQ Newbie
 
Registered: Mar 2004
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks a lot...

Working perfectly....
 
Old 04-02-2004, 02:19 AM   #4
skguha
LQ Newbie
 
Registered: Mar 2004
Posts: 21

Original Poster
Rep: Reputation: 15
one more thing though... how will i know if it is still running or has ended due to some problems....

what if i execute another in the background....will the first script stop running??

Also how do i monitor the different processes that r running...

Thanks a lot...
 
Old 04-02-2004, 02:24 AM   #5
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
you can view running processes with the "ps" command, use "ps aux" to view ALL running processes (see "man ps" for more info). you can use this command: "ps aux | grep run" to view only the "run" process. for realtime monitoring running processes, use the "top" command. you can run different scripts in background, but if you logout the terminal (or xterm) the process will die, because it's a child process of the terminal.

greetinz,
-= iluvatar =-
 
Old 04-02-2004, 02:29 AM   #6
skguha
LQ Newbie
 
Registered: Mar 2004
Posts: 21

Original Poster
Rep: Reputation: 15
thanks for answering the query so quickly...

can i also use kill pid to stop the process??
 
Old 04-02-2004, 02:37 AM   #7
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
yeps, kill <pid> will work for most processes

greetz,
-= iluvatar =-
 
Old 04-02-2004, 08:32 AM   #8
n0b1x
LQ Newbie
 
Registered: Mar 2004
Location: US
Distribution: RedHat 9, Gentoo, Suse 9.1
Posts: 17

Rep: Reputation: 0
if you want to view how much cpu, memory, etc. resources in real time that are being used you can use the
$ top
command as well as control what you want to see by going to the man pages
$man top
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running in the background with Linux AlfaRow Linux - Games 1 11-03-2005 03:08 PM
Running BitTornado on the background UltimatePower Linux - Software 3 02-09-2005 12:20 PM
background running process elbriga Programming 2 09-21-2004 06:08 PM
Running a script in background on a remote machine TheCoffeeMug Linux - Networking 3 11-06-2003 10:08 AM
running screensaver as background contrasutra Linux - Software 9 04-27-2003 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration