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.

Is there a way to check all pids of all users under /home directory, and to run these processes again after a reboot or shutdown?

For example, if user1 was running a psybnc and user2 was running an eggdrop, I wish to re-run these processes, after a reboot, from a single shell command or script.

share|improve this question
1  
Can you elaborate on why you might want to do this? There are several ways to start scripts at bootup, but the best approach depends... –  Paul Aug 28 '12 at 13:15
1  
i have a dedicated server and i have allowed psybnc and eggdrop on it, i have more than 400 users. i accidently got it rebooted, now i want to start all these processes. –  Daud Khan Aug 28 '12 at 13:47
    
i tried writing a shell script but this one just stucks after su'ing in to first user .. the script is #!/bin/bash d=$(gawk -F: '{ print $1 }' /etc/passwd) for i in $d do echo "$i" su "$i" cd ~/psybnc ./psybnc exit done –  Daud Khan Aug 28 '12 at 14:29
1  
ok fixed the script its working fine now .. #!/bin/bash d=$(gawk -F: '{ print $1 }' /etc/passwd) for i in $d do su $i -c 'cd ~/psybnc;./psybnc;exit' done –  Daud Khan Aug 28 '12 at 14:42
1  
Hi Daud, if you have the answer, please add it as an answer and accept it. Thanks. –  Paul Aug 28 '12 at 23:27

1 Answer 1

up vote 1 down vote accepted
#!/bin/bash 
d=$(gawk -F: '{ print $1 }' /etc/passwd) 
for i in $d 
do 
su $i -c 'cd ~/psybnc;./psybnc;exit' 
done
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.