The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Automatically Running Scripts jeffreydavisjr UNIX for Dummies Questions & Answers 4 11-19-2008 05:05 AM
Scripts and changing users bonekrusher UNIX for Dummies Questions & Answers 1 02-05-2008 08:55 AM
Running scripts parallely santho UNIX for Dummies Questions & Answers 4 07-23-2006 12:42 PM
Running three scripts parallelly anwarsait Shell Programming and Scripting 1 07-18-2006 01:20 AM
shell scripts to create 100 users xiamin UNIX for Dummies Questions & Answers 9 09-07-2001 01:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-14-2007
csnewbie csnewbie is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 1
Cool scripts running under different users

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

Join Date: Jan 2007
Posts: 384
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"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0