title: GNU Parallel: How do determine job "slot" you're using?
body: <p>I'm trying to find a way to determine the job "slot" or "core" a command is currently using in <code>parallel</code>. For example, we've all seen a similar image of how <code>parallel</code> distributes commands:</p>
  
  <p><img src="https://i.stack.imgur.com/JHIkf.png" alt="enter image description here"></p>
  
  <p>If I want to know which column a certain process is in, how do I know?</p>
  
  <p>My specific problem illustrated: if set <code>-j 4</code> to only allow 4 jobs to run at once, I want to dynamically know which slot a command is taking, 1 2 3 or 4. The problem is I have some commands that cannot run in parallel, but if I knew which slot I was running in, I'm all good.</p>
  
  <p>Further example, say I have these commands I'm parallelizing:</p>
  
  <pre><code>command resource1 file1.rb
  command resource2 file2.rb
  command resource3 file3.rb
  command resource4 file4.rb
  command resource1 file5.rb
  command resource2 file6.rb
  command resource3 file7.rb
  command resource4 file8.rb
  </code></pre>
  
  <p>Only one command can use each resource at a time. Say I put these commands in <code>parallel</code> like usual with 4 jobs at a time, and job 3 finishes up and it goes to the next in the queue, I now have these running in parallel:</p>
  
  <pre><code>command resource1 file1.rb
  command resource2 file2.rb
  command resource3 file3.rb
  command resource1 file5.rb
  </code></pre>
  
  <p>Notice <code>resource1</code> is being used by two commands, not good. What I need is an environment variable or something to tell the next command to use resource number 4, so that the parallelized commands looks like this:</p>
  
  <pre><code>command resource1 file1.rb
  command resource2 file2.rb
  command resource3 file3.rb
  command resource4 file5.rb
  </code></pre>
  
  <p>I've thought about using the filesystem or some other kind of external signs of which resources are in use, but I figure with parallel processes, there are likely to be race conditions going that route.</p>
  
  <p>I've looked all over, any help is greatly appreciated!</p>