2

I am using Linux SUSE 11 and running a lot of jobs. The path of each job is very long , for example:

cmd>/user/data/some/very/very/very/long/path/to/my/command/run_me param0 param1 param2

When I am running a lot of these commands I want to know which is finished and which is running. Let say after a day or so. Using 'jobs' command I see only the following :

[1]  + Running                        ...
[2]  + Running                        ...
[3]  + Running                        ...
[4]  + Running                        ...

So I can't know which exact command is running.

Using top command is not helpful either, because is is showing the process and not the exact script/program I am running.

My shell is /usr/bin/tcsh

tripleee
  • 175,061
  • 34
  • 275
  • 318
Leonid
  • 57
  • 2
  • 6
  • You should change your shell to [zsh](http://zsh.org/) or [fish](http://fishshell.com/) – Basile Starynkevitch Feb 04 '15 at 09:52
  • And you should have shorter executable paths. For example, make a symlink from `~/bin/run_me` (or `/usr/local/bin/run_me` or `/opt/bin/run_me` ...) to `/user/data/some/very/very/very/long/path/to/my/command/run_me` – Basile Starynkevitch Feb 04 '15 at 09:54
  • 1
    Or Bash or a number of others. I managed to suppress the urge to suggest this to the poster, but now the cat's out of the bag. [`t?csh` should be avoided](http://www.perl.com/doc/FMTEYEWTK/versus/csh.whynot) but I suppose everybody already knows. – tripleee Feb 04 '15 at 09:54

1 Answers1

1

In tcsh, jobs -l gives you a "long" listing which includes the PID. You can then use this number to examine the jobs with ps or groping around in the /proc pseudo-filesystem or whatever.

% jobs -l
[1]  + 19038 Running                       tail --follow=name /path/to/long/and/complex /long/and/complex/files /and/so/on ...

From this listing, you can grab 19038 and see what it's really doing.

% ps -o args= --width 1200 19945
tail --follow=name /path/to/long/and/complex /long/and/complex/files /and/so/on /really/long /etc/motd

as well as

% tr '\0' '\n' </proc/19038/cmdline 
tail
--follow=name
/path/to/long/and/complex
/long/and/complex/files
/and/so/on
/really/long
/etc/motd

or, somewhat messily, with top:

% setenv COLUMNS 512

% top -b -n1 -c -p 19038

(The output is too ugly to show here and does not add anything useful.)

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • jobs -l gives same result but with pid numbers, for example: [2] - 8989 Running ... ps giving only the processes and not the command which was executed. – Leonid Feb 03 '15 at 14:45
  • But you can use this number to examine e.g. `/proc/8989/cmd` to obtain precisely the information you need. – tripleee Feb 03 '15 at 15:27
  • Sorry, but I don't understand how can I examine the /proc/ID/cwd folder? What can I check there? How can I determine the param0 to param2 from my example above? – Leonid Feb 04 '15 at 09:22
  • Sorry, typo (or rather, faulty memory); that's `/proc/8989/cmdline` where 8989 is the PID you want to examine. This shows the full command line, zero-terminated. Updated answer with details. Hope this helps. – tripleee Feb 04 '15 at 09:38