Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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
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
Hi Daud, if you have the answer, please add it as an answer and accept it. Thanks. – Paul Aug 28 '12 at 23:27
up vote 1 down vote accepted
d=$(gawk -F: '{ print $1 }' /etc/passwd) 
for i in $d 
su $i -c 'cd ~/psybnc;./psybnc;exit' 
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .