How can I know my job number when executing a COBOL program through a shell script?
Can you explain a little bit more what you're doing? There are several "numbers" related to your program.
NOTE: In my examples the dollar sign (
$) denotes the command prompt and isn't meant to be typed as part of the command.
When a program runs in Unix it's assigned a process ID. Say I have the program
sleep, and I run it for 100 seconds.
$ sleep 10000
I can then find out its process ID using the command
ps. The process ID would be
9263, for example:
$ ps -eaf|grep sleep saml 9263 5736 0 05:48 pts/1 00:00:00 sleep 10000
When a program is backgrounded, it can continue running without being directly connected to the shell from where it was executed.
$ sleep 10000 &  9370
Here I'm runnning the program
sleepfor 10000 seconds. The ampersand (
&) at the end tells the shell to background it. When jobs are backgrounded they'reassigned a job #. In this case it was assigned job # 1. The
9370is the process ID.
We can find out what jobs are running using the
$ jobs + Running sleep 10000 &
We can use the job # to act on this process either by killing it, or bringing it back into the foreground.
$ kill %1 $ fg -or- $ fg %1
at and batch commands
There are additional places where "numbers" show up in a job # capacity. Scheduled tasks that are queued up using the commands
batchare also assigned numbers.
$ at -f mycrontest.sh 10pm tomorrow job 14 at Sun Jul 8 22:00:00 2007
Compute clustering technologies
#!/bin/bash cobol_program & echo "The COBOL program is running in the background with PID: $!"
man page for
bash under 'Special Parameters'