When are scripts inside etc/profile.d executed?

46,526

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:
46,526
MyTitle
Author by

MyTitle

Updated on September 18, 2022

Comments

  • MyTitle
    MyTitle almost 2 years

    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.

  • MyTitle
    MyTitle over 11 years
    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.
  • Admin
    Admin over 11 years
    using chkconfig is much cleaner on centos
  • Khaled
    Khaled over 11 years
    @MyTitle: So, move your script to init.d folder and use chkconfig to add it to system startup.
  • MyTitle
    MyTitle over 11 years
    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.
  • Khaled
    Khaled over 11 years
    @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.
  • RJS
    RJS over 11 years
    chkconfig require Sys-V compatible script. rc.local not.