The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Feb 2007
Posts: 1
Stumble this Post!
Cool scripts running under different users

what command can i use to tell if a script is running under different users?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Stumble this Post!
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"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0