下面是进程运行列表的示例。从该列表中我们如何获得在 csv 文件中运行的列表进程?
root 94701 8609 0 Jul02 ? 00:00:01 containerd-shim -namespace system -workdir /opt/app/k8s-docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/8328929kdd -address /var/run/docker/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
root 72530 1 8 Jun23 ? 21:14:22 /usr/local/bin/kubelet --logtostderr=true --v=2 --address=0.0.0.0 --node-ip=XXX.XX.XXX.XX --hostname-override=999999 --allow-privileged=true --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --authentication-token-webhook --authorization-mode=Webhook --enforce-node-allocatable=pods,kube-reserved --eviction-minimum-reclaim=memory.available=500Mi,nodefs.available=500Mi --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --volume-plugin-dir=/var/lib/kubelet/volume-plugins
165421 99404 99381 0 02:17 ? 00:00:00 nginx: master process nginx -c /opt/att/data/conf/nginx.conf -g daemon off;
165421 99718 99404 0 02:17 ? 00:00:01 nginx: OneAgent companion process
165421 99720 99404 0 02:17 ? 00:00:00 nginx: worker process
root 101066 61117 0 Jun29 ? 00:00:07 containerd-shim -namespace moby -workdir
165421 110687 110614 0 Jun23 ? 00:00:00 /usr/bin/stunnel /opt/ajsc/etc/config/redis/stunnel.conf
1000 43202 36182 0 Jun29 ? 00:00:00 /bin/sh /u01/oracle/user_projects/domains/base_domain/bin/startManagedWebLogic.sh ManagedServer
root 121802 1 3 Jun16 ? 15:47:09 /opt/app/workload/enabler/java/jdk/bin/java -Xmx16G -Xms16G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Xloggc:/opt/app/workload/enabler/apache_kafka/kafka_2.12-0.11.0.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9998 -javaagent:/opt/app/workload/enabler/Monitor/jmx_exporter-master/jmx_prometheus_javaagent-0.3.1.jar=8081:/opt/app/workload/enabler/Monitor/kafka-0-8-2.yml -Dkafka.logs.dir=/opt/app/workload/enabler/apache_kafka/kafka_2.12-0.11.0.0/bin/../logs -Dlog4j.configuration=file:bin/../config/log4j.properties -cp :/opt/app/workload/enabler/apache_kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-annotatio-Djava.security.auth.login.config=/opt/app/workload/enabler/apache_kafka/kafka_2.12-0.11.0.0/config/security.conf kafka.Kafka config/server.properties
实际上我正在尝试获取系统中运行的进程列表。
答案1
csv-ps 来自https://github.com/mslusarz/csv-nix-tools这样做。
您可以使用此存储库中的其他工具来过滤/处理 csv-ps 输出(csv-grep、csv-cut、csv-sort 等),然后使用 csv-exec 执行命令。