LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 09-10-2010, 09:39 AM   #1
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Rep: Reputation: 18
Checking Processes Running in the Background and Showing Them


Hi,


While executing df command on an AIX Console, by mistake I ended the line with an ampersand:

Code:
bash-3.2$ df -g /etl*&
[1] 94696
bash-3.2$ Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
df -g /etl*
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
[1]+  Done                    df -g /etl*
Since it is a Production Sever and I am not supposed to run any such background job. I typed this command:

Code:
bash-3.2$ jobs
which returned nothing.

Then I tried:

Code:
bash-3.2$ fg
bash: fg: current: no such job
bash-3.2$
I also checked if the df was still running in the background:

Code:
bash-3.2$ ps
    PID    TTY  TIME CMD
 145150  pts/4  0:00 ps
 147334  pts/4  0:00 bash
 261518  pts/4  0:00 -ksh
bash-3.2$
Code:
bash-3.2$ ps -f
     UID    PID   PPID   C    STIME    TTY  TIME CMD
me 197516 338958   1 10:03:56  pts/4  0:00 bash
me 295904 197516   2 10:35:38  pts/4  0:00 ps -f
me 338958 224462   0 10:03:54  pts/4  0:00 -ksh
bash-3.2$

So, what do you think? Am I on the safe side already? Or the process:

Code:
df -g /etl*&
might still be running in the background?

Please advise.
 
Old 09-10-2010, 09:42 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

You are safe:
Code:
bash-3.2$ df -g /etl*&
[1] 94696
bash-3.2$ Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
df -g /etl*
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
[1]+  Done                    df -g /etl*
The blue part tells you that the job has finished.

Hope this helps.
 
1 members found this post helpful.
Old 09-10-2010, 10:11 AM   #3
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by druuna View Post
Hi,

You are safe:
Code:
bash-3.2$ df -g /etl*&
[1] 94696
bash-3.2$ Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
df -g /etl*
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      1.83    9%     7062     2% /
[1]+  Done                    df -g /etl*
The blue part tells you that the job has finished.

Hope this helps.

Hey Thanks for reconfirming what I was thinking of... that a background should stop at some point when it has finished executing.

Thanks again!

By the way, how are you doing?
 
Old 09-10-2010, 10:24 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Quote:
Hey Thanks for reconfirming what I was thinking of... that a background should stop at some point when it has finished executing.
After a background job stops it reports back that is has stopped. This reporting back happens when the terminal is free to use again, which was immediate in your example but can take a while. It also tells you which job/command finished.

Try this harmless experiment:
Code:
$ sleep 4 &
[1] 14860
$ sleep 7
[1]+  Done                    sleep 4
$
The first sleep is put in the background and tells you its jobnumber [1] and PID 14860. If you type sleep 7 immediately after that message and press enter it will take 7 seconds before you get your prompt back. Because the first sleep has finished it will output this directly after sleep 7 is done. It tells you the job number again [1]+, that it is ready Done and what was done sleep 4

Quote:
By the way, how are you doing?
Quite well, Friday evening is just about to start. Weekend is approaching fast
 
Old 09-11-2010, 03:21 PM   #5
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by druuna View Post
Try this harmless experiment:
Code:
$ sleep 4 &
[1] 14860
$ sleep 7
[1]+  Done                    sleep 4
$
The first sleep is put in the background and tells you its jobnumber [1] and PID 14860. If you type sleep 7 immediately after that message and press enter it will take 7 seconds before you get your prompt back. Because the first sleep has finished it will output this directly after sleep 7 is done. It tells you the job number again [1]+, that it is ready Done and what was done sleep 4

Thanks! I experimented with those commands and got the concept.

Quote:
Quite well, Friday evening is just about to start. Weekend is approaching fast
When I posted the question I was at office and it was Friday night yesterday. Now it is getting 2 am which means it is already Sunday here. I had off today! But tomorrow I have office. I love to be at my work desk rather than staying home!

By the way, you use LFS distribution. So, did you build it yourself? I mean, have you experimented building your own Linux Distro?

Anyways, have a nice weekend!

Last edited by Hi_This_is_Dev; 09-11-2010 at 03:22 PM.
 
Old 09-11-2010, 03:29 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,
Quote:
Originally Posted by Hi_This_is_Dev View Post
Thanks! I experimented with those commands and got the concept.
You're welcome
Quote:
By the way, you use LFS distribution. So, did you build it yourself? I mean, have you experimented building your own Linux Distro?
Yes, I've been running (B)LFS with extra packages not mentioned in either of those 2 for several years now. Bit more work than installing a real distro but I find it worth it in the end (more control and no pampering being the main reasons).

Enjoy the rest of your weekend!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
background processes chameleon8636 Programming 6 10-15-2008 06:34 PM
sending processes to background when they are running a.toraby Programming 3 12-23-2007 06:44 PM
background processes digit Linux - Software 3 07-27-2003 12:27 PM
processes in background zetsui Linux - General 8 06-14-2003 12:52 PM
background processes hakum Programming 1 04-08-2002 10:29 PM


All times are GMT -5. The time now is 08:35 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration