Solved

what is PPID = 1 means in ps -ef output

Posted on 2014-04-14
27
1,303 Views
Last Modified: 2014-04-29
I have scheduled a job in the background .. Its a big scp job . As i exit the putty session and re-open another putty and query the ps -ef . I get output as

PPID = 1

ps -ef

root  192512       1

and my job no more running

Can some one please explain me the issue

Thanks
Gaurav
0
Comment
Question by:gaurav12345
  • 10
  • 9
  • 5
27 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40000053
PPID = Parent Process ID

If you want to let your process run in the background, start it like this:

<your command> &

The & (ampersand) starts your command as a background process.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40000061
If you want the output of <your command> to be saved, you can add output/error redirection by adding this:

<your command> 2>&1 >/path/output.txt &
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 166 total points
ID: 40000094
As a default, the init process (PID 1) is the parent of all processes without a parent process.

When a process is run from a login session, the shell it was run from is the parent process. When a shell exits, each child process will receive a SIGHUP signal, which causes the process to exit if a signal handler is not installed to deal with the SIGHUP signal. When a command is invoked with the nohup utility, the signal disposition for SIGHUP is set to ignored, allowing the process to continue executing when the shell exits. Then the parent for this process becomes init (PID 1).
0
 

Author Comment

by:gaurav12345
ID: 40000167
But my scp process stops . Still process seems runnning but scp is no more copying the files
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40000179
can you show how run the command?

Also, run

ps -ef

before you logout and after you login again to confirm that the same process is still running
0
 

Author Comment

by:gaurav12345
ID: 40000208
Hi

I ran
nohup sh sh Datafile_copy_1.sh &  //5 script each

Before exiting putty

 oracle  540822 7286964   0 15:15:16  pts/3  0:00 sh Datafile_copy_2.sh
  oracle 5165218 7286964   0 16:18:44  pts/3  0:00 grep Datafile_copy
  oracle 7135476 7286964   0 15:15:03  pts/3  0:00 sh Datafile_copy_1.sh
  oracle 7176316 7286964   0 15:14:02  pts/3  0:00 sh Datafile_copy_4.sh
  oracle 7200990 7286964   0 15:15:10  pts/3  0:00 sh Datafile_copy_3.sh
  oracle 7389242 7286964   0 15:15:21  pts/3  0:00 sh Datafile_copy_5.sh


After Exiting putty

oracle  540822       1   0 16:20:16      -  0:00 sh Datafile_copy_2.sh
oracle 5165218 7286964   0 16:20:44  pts/3  0:00 grep Datafile_copy
oracle 7135476       1   0 15:15:03      -  0:00 sh Datafile_copy_2.sh
oracle 7176316       1   0 15:14:02      -  0:00 sh Datafile_copy_4.sh
oracle 7200990       1   0 15:15:10      -  0:00 sh Datafile_copy_3.sh
oracle 7389242       1   0 15:15:21      -  0:00 sh Datafile_copy_5.sh


You can ignore the time stamp

Thanks
Gaurav
0
 

Author Comment

by:gaurav12345
ID: 40000209
Only one sh in place of two sh in

nohup sh sh Datafile_copy_1.sh &  //5 script each
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40000249
so the processes are still running but no file copying?

is there any interaction for the scripts like providing password?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40000255
Try with redirecting output, your script could have some output that when not redirected cause the script to stop.

nohup sh Datafile_copy_1.sh 2>&1 >Datafile_copy_1.log &

(and for the other scripts as well)
0
 

Author Comment

by:gaurav12345
ID: 40000286
I had established ssh keys between the two server

This is inside the script

#!/bin/bash
START=$(date +%s)
scp /oracle/data1/cmorstby/*.* <server>:/db_cmorstg/data1
scp /oracle/data2/cmorstby/*.* <server>:/db_cmorstg/data1
scp /oracle/data3/cmorstby/*.* <server>:/db_cmorstg/data2
scp /oracle/data4/cmorstby/*.* <server>:/db_cmorstg/data2
scp /oracle/data5/cmorstby/*.* <server>:/db_cmorstg/data3
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "It took $DIFF seconds" >> /oracle/local/adhoc/gaurav/cmorstg_refresh/Datafile_copy_1.log
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40000306
I assume you've edited out the real server names, right?

Otherwise you have an issue with the server names: <server> - with the redirection characters < and >
0
 

Author Comment

by:gaurav12345
ID: 40000313
Yes i edited the original name .. To be secured
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 334 total points
ID: 40000335
Instead of calling the script with sh, can you try making the script executable first and then starting it directly, like this:

chmod 755 Datafile_copy_1.sh
nohup ./Datafile_copy_1.sh 2>&1 >Datafile_copy_1.log &
0
 

Author Comment

by:gaurav12345
ID: 40000365
Ok does using sh makes a difference in the way the process is being called
0
 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 334 total points
ID: 40000427
Doesn't really make a difference, just the way I write/call scripts.

Are you sure your scp command is working? I wrote a simple test script that keeps running when launched the same way, after the terminal is closed.

You could try adding the -q parameter to your scp command line, this will disable progress, warning and diagnostic messages.
0
 

Author Comment

by:gaurav12345
ID: 40007578
Ok Thanks for the response .. it worked after putting -q
0
 

Author Comment

by:gaurav12345
ID: 40007739
I've requested that this question be closed as follows:

Accepted answer: 0 points for gaurav12345's comment #a40007578

for the following reason:

The expert helped me understanding where my script might be failing
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40007740
You should award points to the expert that helped you understand. Closing with 0 points choosing your own comment is not right.
0
 

Author Comment

by:gaurav12345
ID: 40007840
I am new to the site .How do i that .It was my first question
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40008295
@gaurav12345 - I didn't notice you were new, welcome @EE

You can change the way you close your question by using the 'Request Attention' button above, It's not available at the moment because I already requested attention. A moderator will attend the request and follow up with you.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40028964
My suggestion would be to close this way:

http:#a40000094 - Assist - explanation of "PPID = 1"
http:#a40000335 and http:#a40000427 - Solution to "and my job no more running"
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40030093
What happened ?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40030392
@Omar, asker closed, eenookami will handle this. If you have a different suggestion for closing this question, please post your suggestion.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40031141
@eenookami

Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now