PID / Startscript


 
Thread Tools Search this Thread
Operating Systems Solaris PID / Startscript
# 1  
Old 01-28-2009
PID / Startscript

Hi,

I have a startscript on solaris 10 which does not work properly.

Code:
#!/sbin/sh
PIDFILE=/opt/app_y/PID.log

case $1 in

'start')
        /usr/local/bin/app_y -C /opt/app_y/local.cfg
        echo $! > $PIDFILE
        ;;

esac
exit $?

The problem is that the PIDFILE is empty. What's wrong? How can I geht the PID from the process I started?

Thanks.

rgds,
vic
# 2  
Old 01-28-2009
$! is set to the PID of the last process run in the background (means, with an & at the end or started with bg)
Off the top op my head I know no program or shell builtin to return the PID of the last program run, that's usually done in the program itself.
# 3  
Old 01-28-2009
Is it possible to do a ps -ef and to grep the process, followed by using the awk to filter the PID?
# 4  
Old 01-28-2009
That means I should start the process with ...

Quote:
/usr/local/bin/app_y -C /opt/app_y/local.cfg &
... instead of ...

Quote:
/usr/local/bin/app_y -C /opt/app_y/local.cfg
Sure - I could awk for the PID but I thought there is a "better" way.

rgds,
vic
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing a Startscript

I hope I have found the perfect place for my problem ... I have a dedicated server with some minecraftservers (java) which are connected via a Bungeecord on it. These all have a start.sh which looks in its folder like this: screen -A -m -d -S SERVERNAME java -jar -Xmx2048M -Xms2048M... (10 Replies)
Discussion started by: Spongebob
10 Replies

2. AIX

hacmp application startscript issue

Hi, I am setting up a hacmp oracle cluster with 2 resource groups - one on each node. Binaries are local - so is configuration but its the same on both nodes - so are the startscripts. If I start the cluster, each DB comes up nicely on its homenode. Now I have the problem that when I... (1 Reply)
Discussion started by: zxmaus
1 Replies

3. UNIX for Dummies Questions & Answers

PID value

name the process wit PID value 0? swapper or scheduler or both.... (3 Replies)
Discussion started by: karthi_g
3 Replies

4. 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

5. Shell Programming and Scripting

Pid

How can I put the process id of ,for example, the following script to the pid file? Maybe $$ must be defined in some place? daemon(){ while true; do if then echo "`date +"%H:%M:%S"`" >> $FILE ... (4 Replies)
Discussion started by: mirusnet
4 Replies

6. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

7. 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

8. Shell Programming and Scripting

how to get PID only

The below command returns full line.How can i get only PID from this line ie 15794 from the below example (FI NY) nbswpsa52.ny.ficc.gs.com~ ->ps -ef | grep keepalive | grep -v keepaliveStub | grep -v swapback | grep -v grep ficctprd 15794 1 0 13:12:58 ? 0:01 keepalive (3 Replies)
Discussion started by: kotasateesh
3 Replies

9. UNIX for Advanced & Expert Users

Pid=0

What OS does not use PID=0? is it FreeBSD? (0 Replies)
Discussion started by: nmajin
0 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