Multiple PID for the same script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple PID for the same script
# 1  
Old 09-13-2008
Error Multiple PID for the same script

Hi All,

I have scheduled one script using cron but it's not running. On investigation i have found there are 4 PIDs for the same script.

Please suggest on the following:

1. Is it normal to have more than 1 PID for the script which is being run using cron command?

2. How can avoid the problem and start the script to behave normally?

3. Can i kill all the pid's related to the script and then will cron automatically start(new PID) the script?

Thanks in advance
# 2  
Old 09-14-2008
This all depends on how the script is coded. With no information, I am guessing the script is hanging for some reason.

1. kill off the all of the processes running the script
2. Edit your script: either use some kind of lockfile or search ps output for more than 1 occurrence of your script
3. Make sure the cron envrionment - especially the PATH - is exactly the same as yours is when you test the script and it works. This includes the current working directory.
4. Don't use relative paths to files.
5. Change the cron entry to have the script create a log file .. myscript > /path/to/logfile

Other than that I cannot help you...
# 3  
Old 09-14-2008
Quote:
1. Is it normal to have more than 1 PID for the script which is being run using cron command?
What is that script trying to do..? Are you calling any other scripts/applications inside your script? If that is the case, what you are referrung may be the child processes.

Quote:
3. Can i kill all the pid's related to the script and then will cron automatically start(new PID) the script?
Make entries in the script before the startup to see any existing processes and kill it(its not a fair idea to kill the process if you have a neat option to stop the application process/script)..

Something like below can be used to kill the process.

ps -ef| grep "application" | grep " 1 " | xargs kill -9
# 4  
Old 09-16-2008
Hi All,

The script which is in question is used for deleting the files based on the timestamp which have been calculated using some logic.

The script is not calling any other script.

Now, please suggest:

1. Can I kill all the PIDs related to the script so that it can be started again succesfully. The script is already in the production environment, therefore can't make any other changes. Before moving it to the production, it has been tested successfully and worked in the production environment as well.

2. I see 4 PIDs in total for one scrip of which 2 shows running state and other 2 sleep state.

I need your inputs before Killing the PIDS.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need script to monitor pid.

Need Cron script to monitor the process. if its down, it should alert with an email. (1 Reply)
Discussion started by: pranav987
1 Replies

2. Shell Programming and Scripting

script to extract PID

Can anyone explain the below script which is used to extract the PID? Why they are taking from 10 character and getting the sub string? Note:variable pid has been assigned the PID value initially as below. pid=`sed 's@FILNAME@'$destFil'@g' $scriptname |sed 's@SRCFILE@'$sourceFil'@g' |sed... (2 Replies)
Discussion started by: bk_12345
2 Replies

3. Shell Programming and Scripting

Kill a PID using script

Hi, I wrote a script to kill a process id. I am able to kill the PID only if I enter the root password in the middle of the execution because I did not run as root i.e after i run the script from the terminal, instead of killing directly, it is killing only after entering the pass when it... (12 Replies)
Discussion started by: rajkumarme_1
12 Replies

4. Shell Programming and Scripting

pid.cleanup script.

Hi guys! I have a directory in the production environment from which i have to delete files older then 40 minutes with .pid extention. I wrote a script below for the purpose. #!/bin/bash # # Script to delete specific file older than N minutes. # OLDERTHAN="40" #40 minutes ... (6 Replies)
Discussion started by: sajid.shah
6 Replies

5. Solaris

PID Provider dtrace script

I'm just starting to mess about with dtrace on Solaris. How do I configure a probe in a PID provider dtrace script to trigger when the process being traced exits? I've tried pid$1:::exit where $1 is the PID but I get 'exit' is an invalid probe name (0 Replies)
Discussion started by: JerryHone
0 Replies

6. Shell Programming and Scripting

how to capture PID for a child script

Hi, I'm looking for a method where we can capture the PID and if possible the progress of child process especially the ones running in background. can anyone help? (6 Replies)
Discussion started by: aman jain
6 Replies

7. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

8. Shell Programming and Scripting

Recursive pid script

I'm trying to create a script that allows me to determine all the pid's that spawned from an original process(ie - who's running this command).... I've created a script that searches the processes running based on an argument passed the script. It then is to get the parent pid and look that... (3 Replies)
Discussion started by: jbarnhar
3 Replies

9. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

10. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies
Login or Register to Ask a Question