我正在使用pstree
来观察一系列脚本,即使在使用 时-pla
,我也会得到参数和脚本名称的缩写版本。例如:
sshd,13431
└─bash,13432
└─runJobs.sh,18780 ./runJobs.sh
└─job1.sh,18781 ./job1.sh /path/to/location/of/some/file/that/I/need/to/see/file1.txt /path/to/the/location/of/some/other/file/that/I/need/to/see/file2.txt /path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt/yet/another/long/path/to/a/4th/locatio
└─veryLongNameFor,18782 ./veryLongNameForJob2.sh Argument1_is_very_long arg2_is_also_quite_long The_name_for_arg3_is_even_longer
└─sleep,18783 1000
如您所见verLongNameForJob2.sh
,被修剪了,我没有得到 的完整路径,/yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt
并且我还将其/path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt
与 连接起来/yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt
。即使它们很长,我如何才能在不连接的情况下获得完整的脚本名称以及完整的参数名称?
以下是我为此使用的脚本:
运行作业:
#!/bin/bash
### contents of 'runJobs.sh'
arg1=/path/to/location/of/some/file/that/I/need/to/see/file1.txt
arg2=/path/to/the/location/of/some/other/file/that/I/need/to/see/file2.txt
arg3=/path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt
arg4=/yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt
./job1.sh $arg1 $arg2 $arg3 $arg4
作业1:
#!/bin/bash
### contents of job1.sh
arg1=Argument1_is_very_long
arg2=arg2_is_also_quite_long
arg3=The_name_for_arg3_is_even_longer
./veryLongNameForJob2.sh $arg1 $arg2 $arg3
veryLongNameForJob2.sh:
#!/bin/bash
### contents of 'veryLongNameForJob2.sh'
sleep 1000
答案1
我在我的 Ubuntu 16.04.2 LTS 上复制了这个问题pstree
。我需要更长的路径,但仍然如此。
像 这样的工具pstree
用于/proc
收集信息,因此请阅读/proc/<PID>/cmdline
。如果信息在那里被截断,那真是倒霉。但可能pstree
只是你达到了实施的极限。
就我的情况而言,/proc/<PID>/cmdline
当我超出限制时并没有进行修剪pstree
。
另一个好消息是,中的参数/proc/<PID>/cmdline
用 NULL 字符 ( ) 分隔0x00
。