scripts running under different users


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers scripts running under different users
# 1  
Old 02-14-2007
Tools scripts running under different users

what command can i use to tell if a script is running under different users?
# 2  
Old 02-14-2007
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"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running scripts from a list

I am writing a bash script to run test some scripts. The names scripts of the scripts to tests are stored in an array. scptArr='chcksfrd.bash' scptArr='compute-misfit.bash' scptArr='compute-travel-times.bash' scptArr='create-data-tinv.bash' scptArr='create-docs.bash' ... (3 Replies)
Discussion started by: kristinu
3 Replies

2. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

3. Shell Programming and Scripting

sequential running for 2 scripts

Hello I have a script that has 2 scripts that must be executed one after the other. however, when I run the script, the 2 sub-scripts are run in parallel. any idea how to fix this without using sleep command? thank you (7 Replies)
Discussion started by: melanie_pfefer
7 Replies

4. Shell Programming and Scripting

Running scripts via su

Hi All, Am using the below command to start my application using the root user su - bin -c "/home/bin/test/start.sh" but am getting the error becaue i have set some environment varibales in bin .profile when i execute the command start.sh by logging directly into bin account it's... (8 Replies)
Discussion started by: ravi.sri24
8 Replies

5. Shell Programming and Scripting

Running scripts through cronjob.

Hello everybody, I'm trying to run a shell script in crontab file. But anyhow it's not getting executed. Following is the command that I've used in crontab. 30 07 * * * . ./.cronprofile;/om/reports/reportscripts/jitu/prod/prd_pre_to_post.sh 35 11 * * * .... (3 Replies)
Discussion started by: jitu.jk
3 Replies

6. UNIX for Dummies Questions & Answers

Scripts and changing users

Hi, I am writing somescripts to shut down some services in Korn Shell. Some of the services are under different owners. For example when I want to shutdown NXserver I need to be "root", but when I shut down the webserver I need to be under a different user. Manual I would use "su root" and... (1 Reply)
Discussion started by: bonekrusher
1 Replies

7. UNIX for Dummies Questions & Answers

editing sqlplus id@passwd in multiple scripts, users and directories

hi all, i was given by my supervisor a task to search for scripts which contain oracle sqlplus i.e "myusername/mypasswd @myDB" in every /home/userfolder, which are, all the scripts made by different user. I've done some find command to search string for sqlplus, but it may up too long to respond.... (8 Replies)
Discussion started by: Helmi
8 Replies

8. UNIX for Dummies Questions & Answers

Running scripts parallely

Hi, Posting my first query in this Forum,here's my query i want to execute 100 .sql files in unix having some code for connecting with db and executing procedures inside that,that to be run parallel like threads.want to run all the 100 .sql files simultanously. thanks in advance. (4 Replies)
Discussion started by: santho
4 Replies

9. Shell Programming and Scripting

Running three scripts parallelly

Hi All, We have three shell script batch, which extract data from three different systems(oracle, db2, db2/400). By running each shell script batch, the data is extracted from respective systems. while the batch is running, job date, system_name, start_date and end_date will be inserted into... (1 Reply)
Discussion started by: anwarsait
1 Replies

10. UNIX for Dummies Questions & Answers

shell scripts to create 100 users

Hello i need a shell script to create 100 users i am running hp-ux......... startegy is something like this craete a shell script !/bin/ksh counter=1 while do { useradd usr$counter passwd usr$counter # here begins my problem when i say passwd usr$counter #it again prompts... (9 Replies)
Discussion started by: xiamin
9 Replies
Login or Register to Ask a Question