# Execute Custom Script Using yc-360 Script
The yc-360 script captures a 360-degree data snapshot from your application environment at the moment a problem occurs.
To support custom workflows, the captureCmd argument allows you to override the default artifact capture logic and execute a user-defined script. When this argument is provided, the yc-360 script resolves the given process token or PID and invokes the specified script once per resolved process ID. The script receives the target PID through an environment variable named pid.
# How It Works?
Suppose your host is running multiple Java processes:
$ ps -ef | grep java
ec2-user 8168 1 0 Sep09 ? 00:02:14 java -Xms2g -Xmx4g -DlogDir=. -DuploadDir=. -jar webapp-runner-9.0.52.1.jar -AconnectionTimeout=3600000 --port 8080 webBroker.war
ec2-user 12667 12628 31 01:16 pts/2 00:00:01 java -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/tmp/buggy-app.gc -jar buggyApp.jar
2
3
You want the yc-360 script to execute a custom script for the process running buggyApp.jar. You can achieve this by passing either the PID 12667 or the process token buggyApp to the p argument.
Here's what happens internally:
- The yc-360 script resolves the process ID or token provided via
pinto one or more Java process IDs (PIDs). - For each resolved PID, it sets an environment variable:
pid=<value>
- It then invokes the
captureCmdusing the system shell:
/bin/sh -c "<captureCmd>"
The environment variable pid is available inside the script for reference.
- Standard output and error streams from the custom script execution are captured and logged by the yc-360 script.
# Example Usage
# CLI Example
Select your environment below to see how to pass captureCmd argument in CLI:
# YAML Configuration Example
Select your environment below to see how to pass captureCmd argument in YAML configuration file:
If the process token buggyapp resolves to two PIDs, such as 1234 and 2345, the yc-360 script will:
Set
pid=1234and execute/opt/scripts/diagnostics.shSet
pid=2345and execute/opt/scripts/diagnostics.shagain
Each invocation is isolated to a specific PID, giving full control to the custom script for handling that process.