1846616 Members
2196 Online
110256 Solutions
New Discussion

script problem

 
SOLVED
Go to solution
Thomas Kopp
Occasional Advisor

script problem

Moin,
I have made a script to run a software at boot.

I have linked it in /sbin/rc3.d, I have created the config file in /etc/rc.config.d

if I try to run it in a shell, it work.
but ...
if I reboot the server, start and ( I can see it with a ps -ef starting up) and stop without an error or log.

Can you check the script and give some comments.
5 REPLIES 5
Ramkumar Devanathan
Honored Contributor

Re: script problem

hi,

I believe you wish to run these with su command. avoid the '-' sign after the su call.

call it in this manner -

su sc ...

instead of

su - sc ...

'-' runs a shell with the environment settings of the particular user. the script will never return until that shell is exited.

A similar question last night... the same problem...

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x127d38dfa974d711abdc0090277a778c,00.html

HTH.

- ramd.
HPE Software Rocks!
Jean-Louis Phelix
Honored Contributor

Re: script problem

Hi,

I'm sorry but I think that it should work. with 'su - sc' you will set the environment, execute the command and logout. I Think that your problem is perhaps related to some differences in env variables settings (see man su), or some variables not set (like DISPLAY) because when you run it at boot time your process is not attached to any terminal (you can easily find some tests in most .profile files). Try finally to redirect nohup output rather than rc script output (use "nohup $SC_BINPATH/xscmanmx > /tmp/whatishappening 2>&1).

Regards.
It works for me (© Bill McNAMARA ...)
David_246
Trusted Contributor
Solution

Re: script problem

Hi,

Good comment to user the redirect of stout to stderr. This makes your output more complete.

I also have an issue with the folowing line :

/usr/bin/su - sc -c "nohup $SC_BINPATH/xscmanmx" & > /dev/null 2>&1

This should be :

/usr/bin/su - sc -c "nohup $SC_BINPATH/xscmanmx >/dev/null 2>&1" &

Whenever su - generates an error, you want to see it !! Whenever your program xscmanx generates one, I assume you don't want to see it.

I would recommend you keep the su -, as in this case your user profile gets loaded which might important path-variables and $home settings.

Good luck.

Regs David
@yourservice
Thomas Kopp
Occasional Advisor

Re: script problem

Thanks David,

looks better now.
What do you think, do I still need the trap command?

Thomas
Ramkumar Devanathan
Honored Contributor

Re: script problem

Sorry for the misinformation about shell not exiting, and thanks jean for pointing that out.

- ramd.
HPE Software Rocks!