Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using CentOS 6.3, I failed to add a script in inittab to let it start automatically.

myscriptid:2345:respawn:myscript_path

In the script, I have a su myusername -c command, if I run it directly, it prompts me to enter the password, then the script can run. So my question is if I add it to inittab, will it be called successfully?

share|improve this question

migrated from serverfault.com Dec 17 '12 at 19:07

This question came from our site for system and network administrators.

1 Answer 1

First, accepted practice is to never run an initialization script outside the standard /etc/init.d (or the newer startup methods) unless it is absolutely necessary.

Why not create a script, put it in /etc/init.d with appropriate symbolic links to /etc/rc.5 or /etc/rc.3 (as appropriate) for starting and stopping such a service. The service command calls scripting in /etc/init.d.

So please reconsider reconstructing your startup scripting.

Now for the specific answer, if the scripting you have runs as the root user, then any su will not require a password.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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