Visit Our UNIX and Linux User Community


problem starting a process on solaris from other user


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users problem starting a process on solaris from other user
# 1  
Old 08-09-2009
problem starting a process on solaris from other user

Hi Gurus,

I have a server that has to users.

1) root
2)net1

there are several processes running on my server

one of the process is CMIS_STACK process which is a compiled C code

when this process goes missing then i restart this process manually in the following manner



su net1(the process can only be started from net1 user)
cd /net1/bin
CMIS_STACK &


and the process starts successfully



now i have written a script that starts the process automatically if it goes missing

i have a process.txt file that contains all the important processes

ps -ax > process.txt
grep "CMIS_STACK" process.txt
if [ $? -ne 0 ]
then
date > error.log
echo "CMIS_STACK not running" >> error.log
su netmon
cd /net1/bin
CMIS_STACK &
echo "process startted successfully" >> error.log
fi


now if i run the above script , it exits without restarting the process. I am not able to figure out , what is the problem.

is this related to the swithching of the users in the script.

please Gurus help me out tosolve this problem Smilie


I have to implement this script as soon as possible

Thanks
# 2  
Old 08-09-2009
Hi.

Run your script manually, and when it returns to command prompt, type "exit", or press Control-D and see what happens.

When you run su like you are, it will fork a new shell (and wait for input). When you exit this shell it'll continue with the rest of the script (as root).

(you mention a user called net1, but your script shows a user called netmon)

Code:
ps -ax > process.txt
grep "CMIS_STACK" process.txt
if [ $? -ne 0 ]; then
  date > error.log
  echo "CMIS_STACK not running" >> error.log
  su - net1 -c "nohup /net1/bin/CMIS_STACK &"
  echo "process startted successfully" >> error.log
fi

You should also probably run this with "su -" not just "su".

The "process started successfully" line is meaningless for a number of reasons. Mainly because a) you never test the result after starting the CMIS_STACK program, and b) when you run it in the background a new process is forked and it's unlikely anything wrong will happen before you could test it.
# 3  
Old 08-10-2009
Hi


It worked . I am extremely thankful to you for your solution.

Looking forward to seek more solutions from you.

---------- Post updated at 11:15 AM ---------- Previous update was at 04:54 AM ----------

code

su - net1 -c "nohup /net1/bin/CMIS_STACK &"

/code

this line made it work

---------- Post updated at 11:16 AM ---------- Previous update was at 11:15 AM ----------

Quote:
su - net1 -c "nohup /net1/bin/CMIS_STACK &"
Thanks

Previous Thread | Next Thread
Test Your Knowledge in Computers #757
Difficulty: Medium
The MOSFET is the least common semiconductor device in digital and analog circuits.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Solaris, grant user to kill another process

the task is grant user1 to kill another (for example user2) process. My steps: by root: usermod -P "Process Management" user1 login user1 user1@server (~) pfexec kill <PID> the result is: ksh: <PID>: not found or user1@server (~) pfexec pkill <PID> the result: nothing happens, still... (0 Replies)
Discussion started by: dsyberia
0 Replies

2. AIX

Changing process id after starting

Hi We are in the situation where we want to start WebSphere using teh default SSL port of 443. In order to do this we can changed the WAS ssl port from 9443 to 443 and start as root. We would prefer not to start as root but the restriction of using ports < 1024 comes into play. We could install... (3 Replies)
Discussion started by: hukcjv
3 Replies

3. Solaris

Problem starting x11vnc on solaris 9

Hello, I installed x11vnc on a solaris 9 server. #SunOS gandalf 5.9 Generic sun4u sparc SUNW,Ultra-60 When i run x11vnc i get following errors bash-2.05# /usr/local/bin/x11vnc -display :0 17/06/2010 23:34:08 x11vnc version: 0.9.9 lastmod: 2009-12-21 pid: 16203 17/06/2010 23:34:15... (0 Replies)
Discussion started by: sunny_a_j
0 Replies

4. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

5. UNIX for Dummies Questions & Answers

Starting a process whose ppid should be 1

How can I start a process with ppid as 1 instead of my current shell pid? (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

6. Solaris

Solaris 8 logon problem with normal user

Hello. I have problem in Solaris 8. I can logon cde with root there is no problem. When I logon with normal user I am recieving black screen after 10 15 second login screen (cde pasword screen) coming again. 1 years ago we resolved same problem. We found a file It must be run with admin... (1 Reply)
Discussion started by: FATIH1453
1 Replies

7. Shell Programming and Scripting

facing problem in starting a process in background using shell script.

hey all, i am working on sun solaris machine and i want to start a process in background using shell script (actually i wanna start tomcat server using shell script). please dont tell me that append a & at last because this is not working in the shell script. i have also used nohup and... (8 Replies)
Discussion started by: dtomar
8 Replies

8. Solaris

Problem starting Sendmail on Solaris 9

Hi, I am getting problem in starting up Sendmail on solaris. When I do /etc/init.d/sendmail start in Process list it shows sendmail process properly. But when I do portcheck by netstat it doesn't show Port 25/smtp. What could be the problem ? Thanks NeeleshG (6 Replies)
Discussion started by: neel.gurjar
6 Replies

9. OS X (Apple)

process starting

Hello everybody! I got a question on process starting. I installed e.g. squid on my Mac and all is working well, but i wanted to figure out what process or script is starting squid on booting the machine. I searched for a while but i could not find where i can change these configuration. ... (2 Replies)
Discussion started by: count_zero
2 Replies

10. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

Featured Tech Videos