How to determine which script is being executed by bash?

GoldfishGrenade

How would I determine which script is being executed by a process? When I use:

ps -u user

I get the following output:

10005194 26932  0.0  0.0 112700  1544 ?        Ss   Jun03   0:00 -bash
10005194 27117  0.0  0.0 112700  1528 ?        Ss   Apr24   0:00 -bash
10005194 27164  0.0  0.0 112700  2040 ?        Ss   Jun06   0:00 -bash
10005194 27404  0.0  0.0 112700  1544 ?        Ss   May27   0:00 -bash
10005194 27484  0.0  0.0 112700  1528 ?        Ss   Apr23   0:00 -bash
10005194 27531  0.0  0.0 112700  1528 ?        Ss   May22   0:00 -bash
...

There are hundreds of lines. I know that there are a number of scripts that this user is executing, but I would like to narrow down which of the scripts is holding onto threads. Is there a way to do this?

cas

Use the w (for "wide") option.

From man ps (search for wide):

w Wide output. Use this option twice for unlimited width.

e.g. ps ww -u cas:

$ ps ww -U cas | grep bash
 1350 pts/0    Ss     0:00 -bash
18345 pts/34   S      0:00 /bin/bash /home/cas/bin/myscript.sh
21293 pts/34   Ss+    0:00 bash

The -bash is a login shell.

The plain bash is a non-login interactive shell - the tty pts/34 is the same so you can tell that it is the parent shell (or distant grand-parent) of the myscript.sh bash shell.

Using /usr/env/bin bash prevents you from determining which script is running. Instead you should specify exactly were the bash executable is for the machine you're running on.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to determine if my PowerShell script is being executed by Windows Terminal?

Programatically determine if an script is being executed on laptop or desktop?

How to determine if sql script is executed parallel or not?

How to determine which Textfield is being changed in SwiftUI

How to determine which records are being deleted?

VBA how to determine which application is being used

How can my script determine whether it's being run by bash or dash?

Cronjob script not being executed

Bash script which can be executed after password is supplied

How to know which command is being executed without stopping it?

How to know which line of code was being executed when a signal is received

How to return the PID from a bash script executed from a bash script

How to determine which script that python is executing?

Python and Bash - how to "print" output in the file and "tail" it while it is being executed

Content script code is not being executed

script not being executed in HTML page

How do you determine which formatter is being used for VS Code?

How do you determine which backend is being used by matplotlib?

How to determine which meteor packages are being used in my meteor project

How to determine which line specific line of a file being read

How to determine which type of a function from a union is being used?

Bash Script not executed

Latexmk, from Makefile, from bash script, from Cron - Latexmk not being executed

How to distribute code to be executed by an external command? Bash script?

How to obtain the path of a Bash script, when it’s executed through a symlink?

How to executed if statement that checks the exit status from a function in bash script?

How to check if a bash script is executed inside or outside a vagrant machine?

How to get the name of the user who executed a bash script as sudo?

How do I make a batch script exit if executed by bash?