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 :slight_smile:

I have to implement this script as soon as possible

Thanks

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)

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.

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

Thanks