1

I'm trying to auto-run a bunch of processes at system startup, after a user logs in. Here is the create_processes.py script that I will use to start some processes:

#!/usr/bin/python
import subprocess 

def f1():
    while True:
        time.sleep(2)
        print "I'm alive"
if len(sys.argv) < 2:
    print "assuming main"
    subprocess.Popen([""/usr/bin/python",sys.argv[0],"f1"])
elif sys.argv[1] =="f1":
    f1()

If I directly invoke it or if I try with nohup python create_processes.py 2>&1 & everything works fine.

The problem rises when I try to make it run invoked by a script inside the /etc/profile.d/ folder. Such script simply contains the above command. Using ps I can not find the children anymore. What happens in such context?

Thank you for your time and sorry for my poor English.

0

The files in /etc.profile.d/ are sourced when /etc/profile is executed.

Here are the relevant lines from /etc/profile:

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

From this lines we can see, that only files which names ends with .sh are going to be sourced.

If the name of your custom file doesn't end with .sh, rename it accordingly, otherwise it will not be sourced.

| improve this answer | |

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.