Wie kann ich unbegrenzt Informationen von pstree erhalten?

288
drjrm3

Ich verwende pstreeeine Reihe von Skripten, und selbst bei der Verwendung -plabekomme ich verkürzte Versionen von Argumenten und Skriptnamen. Als Beispiel:

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 

Wie Sie sehen, verLongNameForJob2.shist abgeschnitten, ich bekomme nicht den vollständigen Pfad dafür /yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txtund ich werde auch mit /path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txtverkettet /yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt. Wie kann ich vollständige Skriptnamen mit vollständigen Argumentnamen ohne Verkettung erhalten, auch wenn sie sehr lang sind?

Hier sind die Skripte, die ich dafür verwendet habe:

runJobs.sh :

#!/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 

job1.sh :

#!/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

1 Antwort auf die Frage

0
Kamil Maciorowski

Ich habe das Problem mit pstreemeinem Ubuntu 16.04.2 LTS repliziert. Ich brauchte lange Wege, aber immer noch.

Tools wie der pstreeEinsatz /procum Informationen zu sammeln, so lesen /proc/<PID>/cmdline. Es ist ein Pech, wenn die Informationen dort abgeschnitten werden. Es kann jedoch sein, dass Sie nur das Limit Ihrer pstreeImplementierung erreichen.

In meinem Fall /proc/<PID>/cmdlinewurde nicht getrimmt, als ich das Limit überschritten habe pstree.

Eine weitere gute Nachricht ist, dass die Argumente /proc/<PID>/cmdlinemit NULL-Zeichen ( 0x00) getrennt sind.