4

My goal is to get the command line args of a java process. I am running ps aux | grep java> out.log to see the full argument list. Problem is that it's truncated at approx 4k bytes. Java is invoked from a build tool (maven) so I don't have much influence on the arguments. Most of the long argument list is related to classpath entries. On the windows platform the argument list is approx 12Kb.

How can I see the full command line arguments in Linux even if they are longer than 4K? I am running on Linux Mint Petra. I've tried with the processes explorer but it also truncates (and it won't let my copy-paste the arguments)

shaft
  • 2,147
  • 2
  • 22
  • 38

4 Answers4

5

Just found this explanation how-do-i-increase-the-proc-pid-cmdline-4096-byte-limit. It basically tells me that the linux kernel has a hard limit (unless I want to recompile it). The best solution for me was to run jconsole. This does the trick for me at least for java processes.

Community
  • 1
  • 1
shaft
  • 2,147
  • 2
  • 22
  • 38
2

You can try

ps axwwo args

This shows all arguments that are stored in the process table.

But the right way would be to get more familiar with your build tool. If you master this maven gives you perfect control.

blafasel
  • 1,091
  • 14
  • 25
  • This question was less related to maven than to Linux. Consider you have a java process running on a server with a long classpath, then knowing your build tool won't help at all to get its classpath (from outside!). For me the responsiblity of a task manager is to show you the details of a process, including command line args. Indeed 4k should be enough for most cases so I don't blame it on linux for this restriction, it's just a special scenario. I was just curious if there was a way in linux to force the retrieval of such command line args. – shaft Apr 28 '14 at 11:07
2

There is a hardcoded limit of 4k in the cmdline buffer in Linux, so there's not much you can do about it unless you feel like downloading the kernel's source and modify it to allow a bigger buffer.

As a workaround you could execute maven with the -X option for full debugging and using tee to write to standard output and also a file: mvn -X clean install | tee my_log_file.txt and then try to find the information you're looking for in my_log_file.txt

morgano
  • 17,210
  • 10
  • 45
  • 56
  • Good idea thanks. In the meanwhile I found the tool "jconsole" which can list the full classpath of any running java process. – shaft Apr 28 '14 at 11:02
-1

Just note for some, how are not able to use GUI tools. Another alternative is using of jinfo tool, included in JDK. Just be aware of, that you need to use same version of JDK as java, you are running (some time there is used JRE instead of java from JDK).

just use jinfo <pid>

Jan
  • 70
  • 8