2
/apps/data/service/bin/startup.sh

This is the script i want to be executed during RHEL booting. I want it to be run in runlevel 3 only.

And i want this script to be started as specific user, eg:appadmin

So, what's the recommended way of achieving this? I read lot of posts on this, and I am confused now.

Just creating a soft link for /apps/data/service/bin/startup.sh under /etc/init.d would be enough to start the script? Is my understanding right?

Since i want the script to be ran as specific user, should i create a file under init.d like below?

su appadmin -c "/apps/data/service/bin/startup.sh" 

and make it executable?

3

You should definitely look into /etc/init.d/functions. There is a nice function called daemon. It will run your program as specified user.

Example:

daemon --user=your_user /apps/data/service/bin/startup.sh &>/dev/null & ← or some logfile maybe…

Init script you can copy from some other service ;-)

HTH, Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.