Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I added some scripts from root inside etc/profile.d to execute at startup time. But when will these scripts be executed if I login into system as a non root user? I want to start LDAP-server at start-up time, independently from which user has first logged in.

I use CentOS 6.3.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

In order to add a script to be started during system startup, you need to use chkconfig after putting the script in /etc/init.d folder.

This has nothing to do with user login.

share|improve this answer
    
Sorry, I have mistake in my question: I putted some scripts inside etc/profile.d, not /etc/init.d.. My purpose is to run some .sh files when system is starting. Thanks. –  MyTitle Oct 3 '12 at 7:58
    
@MyTitle: So, move your script to init.d folder and use chkconfig to add it to system startup. –  Khaled Oct 3 '12 at 8:23
    
Can you please say, who execute this scripts? This scripts executed automatically by root? I want to execute some .sh file where root doesn't have permissions. –  MyTitle Oct 3 '12 at 8:55
    
@MyTitle: It will be executed as part of system startup process. If you want to execute it under different user, you may need to customize your script. –  Khaled Oct 3 '12 at 9:08

Files in /etc/profile.d/ are run when a user logs in (unless you've modified /etc/profile to not do this) and are generally used to set environment variables.

share|improve this answer

If you want to run it at system startup you can add it to /etc/rc.d/rc.local.

Or make an init script, check http://www.debian-administration.org/articles/212 for more information about runlevels.

share|improve this answer
    
using chkconfig is much cleaner on centos –  coincoin Oct 3 '12 at 8:12
    
chkconfig require Sys-V compatible script. rc.local not. –  RJS Oct 3 '12 at 21:16

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.