![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scripts and changing users | bonekrusher | UNIX for Dummies Questions & Answers | 1 | 02-05-2008 04:55 AM |
| Automatically Running Scripts | jeffreydavisjr | UNIX for Dummies Questions & Answers | 3 | 11-01-2006 09:35 AM |
| Running scripts parallely | santho | UNIX for Dummies Questions & Answers | 4 | 07-23-2006 09:42 AM |
| Running three scripts parallelly | anwarsait | Shell Programming and Scripting | 1 | 07-17-2006 10:20 PM |
| shell scripts to create 100 users | xiamin | UNIX for Dummies Questions & Answers | 9 | 09-06-2001 10:47 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
what command can i use to tell if a script is running under different users?
|
| Forum Sponsor | ||
|
|
|
|||
|
ps -e -o"user,args" | grep <scriptname> | nawk '{ print $1 }' | sort -u
Maybe you have to replace "nawk" by "awk" depinding on your system. example: ps -e -o"user,args" | sc[r]ipt.sh | nawk '{ print $1 }' | sort -u Put 1 letter of the <scriptname> between "[" and "]". That way the "grep" itself will not be part of the result. Compare e.g. # ps -ef | grep sshd user3 306 1 0 Feb 09 ? 0:16 /usr/lib/ssh/sshd user2 14740 14733 0 17:25:44 ? 0:06 /usr/lib/ssh/sshd user1 14733 306 0 17:25:43 ? 0:00 /usr/lib/ssh/sshd user2 23404 14773 0 21:46:36 pts/1 0:00 grep sshd or # ps -ef | grep ss[h]d user3 306 1 0 Feb 09 ? 0:16 /usr/lib/ssh/sshd user2 14740 14733 0 17:25:44 ? 0:06 /usr/lib/ssh/sshd user1 14733 306 0 17:25:43 ? 0:00 /usr/lib/ssh/sshd effectively "ps -ef | grep ss[h]d" will do the same as "ps -ef | grep sshd | grep -v grep" |
|||
| Google The UNIX and Linux Forums |