Is it possible to find the complete command list to be executed in a sub-shell?
0
votes
3
answers
85
views
I face a situation that features Bash scripts on a Linux installation that asynchronously run system tools with a delay, via a
-bash
( sleep 10 ; some_command ) &
construct. The scripts that perform these delayed commands cannot be changed, and they are triggered by system processes outside my direct control.
I need to detect this some_command
"about to happen" from another bash script. The name of the command is one of a few known alternatives (e.g. systemctl
), and I only need to detect if it has been scheduled to run after the timeout implemented by sleep
.
I can identify any "active" sleep
calls via ps
and from there on their parent PIDs. However, the parent PID belongs to the script featuring the sub-shell call, not the sub-shell itself.
Is there any way to retrieve
* the PID of a sub-shell by knowing the currently running command (in this example, sleep
), and from there
* the complete command-list passed to that sub-shell
with command-line tools?
Asked by AdminBee
(23588 rep)
Jan 29, 2025, 04:45 PM
Last activity: Jan 31, 2025, 02:56 PM
Last activity: Jan 31, 2025, 02:56 PM