Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running a job in AIX

2 views
Skip to first unread message

Stephen...@gmail.com

unread,
Mar 22, 2006, 9:49:53 AM3/22/06
to
Looking to compare features of AIX and OS400 ...

How do you submit a job to run on AIX? Once it is running, can I hold
it, release it, cancel it? Can I display how much CPU it is using, can
I display all the jobs running on the system and see the share of the
system each job is using?

Here is a scenario. I run a job every morning. It checks an ftp site
for a file. If the file is there, it receives the file, copies the file
into an sql table, then runs an sql procedure to process the data in
the table.

What AIX facility would I use to submit the job everyday at 8am? The
code that runs this job, what language would it be written in? The
automated FTP work, how is that done?

What facility would I use to copy the FTP stream file, containing comma
delimeted columns in text line rows, into an SQL table?

Then the final step, how would I initiate the sql procedure to process
the received table?

Here is how all this works on the as400:

To submit a job you use the SBMJOB command. The job is placed on a job
queue which feeds into a subsystem. To hold a job on the job queue or
when it is running use the HLDJOB command. To release it, use the
RLSJOB command. To kill the job, ENDJOB.

Once the job is running you DSPJOB to see the call stack, how much CPU
it is using, what output it has created and put on output queues (
spooled files = printed output ). To see all the jobs running on the
system use the WRKACTJOB command.

To run my FTP job every day I use the job scheduler. The language CL (
control language ) is used to program the steps of the job.

To automate the FTP process you code the FTP script in a source member
and then run the FTP command from the CL program with overrides to the
FTP input and output source members.

The FTP step places the files received from the FTP site in a stream
file in the IFS. The IFS ( integrated file system ) is the as400
equivalent of a UNIX directory tree. A stream file is a file in a
directory.

The CL command CPYFRMSTMF ( copy from stream file ) is used to copy the
comma delimeted data from the received FTP file into a database table.

To run the sql procedure from the CL program that is running the steps
of the job you use the RUNSQLSTM ( run sql statement ) command.

-Steve

steven_nospam at Yahoo! Canada

unread,
Mar 22, 2006, 11:12:20 AM3/22/06
to
Stephen...@gmail.com wrote:
> Looking to compare features of AIX and OS400 ...
>
> How do you submit a job to run on AIX? Once it is running, can I hold
> it, release it, cancel it? Can I display how much CPU it is using, can
> I display all the jobs running on the system and see the share of the
> system each job is using?

The "at" command that can be used to start a batched job now or at a
specific time. There is also the cron daemon that lets you submit a job
on a regular basis, such as every morning at 8am. There is the "atq"
command to show what is in the queue, and "atrm" command to cancel
jobs.

Our company created special "batch" queues in the qdaemon subsystem
that lets us queue up batch jobs much like you would do for a print
job. For example, we create a short script that sets our environment
and then calls a COBOL program, and then we simply use the lp command
to submit to that queue, whose backend program is /bin/ksh instead of
piobe (the standard printer I/O backend).

CPU usage can be seen for each process using the ps command.

> Here is a scenario. I run a job every morning. It checks an ftp site
> for a file. If the file is there, it receives the file, copies the file
> into an sql table, then runs an sql procedure to process the data in
> the table.
>
> What AIX facility would I use to submit the job everyday at 8am? The
> code that runs this job, what language would it be written in? The
> automated FTP work, how is that done?
>
> What facility would I use to copy the FTP stream file, containing comma
> delimeted columns in text line rows, into an SQL table?
>
> Then the final step, how would I initiate the sql procedure to process
> the received table?

This can easily be done using a Korn shell script, FTP service, and a
.netrc file. I would put the script in CRON to run at 8am, it would
start, connect to the FTP site, retrieve the file (if any exist),
confirm whether a file was received, and then call the appropriate SQL
script to do the insertion.

I would recommend that you get a copy of "Learning the Korn Shell" from
O'Reilly & Associates or "Korn Shell Command And Programming Language"
from Bolsky/Korn as these can help get you familiar with scripting
techniques for the AIX environment.

Keep in mind that your UNIX system may be using Bourne shell or C-Shell
instead of Korn. In that case, you will want to pursue other guides.

If time permits, I will publish a sample Korn shell script.

Steve

Stephen...@gmail.com

unread,
Mar 22, 2006, 12:00:29 PM3/22/06
to

thanks.

are there any shells that use descriptive names for their commands?
Also, do shells have prompting facilities that prompt the parameters of
the command ( I am aware of the man command to read the help text )

another thing ... When a shell script is running does it log the steps
it is running to a log file of some sort? On the as400 I can run a job
in LOGCLPGM(*YES) mode. Each CL command that is run is written to the
joblog. The joblog can be displayed as the job is running and saved
after it completes.

Here is a screen shot of the CPYFRMIMPF ( copy from import file )
command on the as400 when it is prompted:

Copy From Import File (CPYFRMIMPF)

From stream file . . . . . . . .

From file:

File . . . . . . . . . . . . . Name

Library . . . . . . . . . . *LIBL Name, *LIBL, *CURLIB

Member . . . . . . . . . . . . *FIRST Name, *FIRST

To data base file:

File . . . . . . . . . . . . . Name

Library . . . . . . . . . . *LIBL Name, *LIBL, *CURLIB

Member . . . . . . . . . . . . *FIRST Name, *FIRST

Replace or add records . . . . . *ADD *ADD, *REPLACE,
*UPDADD
Stream file record length . . . *TOFILE Number, *TOFILE

From CCSID . . . . . . . . . . . *FILE 1-65533, *FILE

Record delimiter . . . . . . . . *EOR Character value,
*ALL...
Record format of import file . . *DLM *DLM, *FIXED

String delimiter . . . . . . . . '"' Character value,
*NONE

steven_nospam at Yahoo! Canada

unread,
Mar 22, 2006, 1:20:21 PM3/22/06
to
The Korn shell is about as descriptive as you get, but I have not tried
all flavors. Here is an example of the if statement to see if the file
was retrieved from the FTP website...anything after a # on the line is
a comment. I grouped all of it together in the { } brackets so that we
could use "tee" command to write all output that shows up on the screen
to a log file as well.

# Check if retrieved file exists and is non-zero size
{
if test -f ${FTPFILE} -a -s ${FTPFILE}
then
echo "FTP file was retrieved:"
ls -l ${FTPFILE}
else
echo "FTP file does not exist or is empty"
fi
} | tee -a /logs/ftp_retrieve.log


The Korn shell offers "for..do..done" loops, "if..then..else..fi"
statements, "case..in..esac" statements, arrays, and other good stuff.
You mostly use generic UNIX commands with redirection techniques to
filter out the data you want or select fields. A good thing to learn is
how to use the redirection (output from one UNIX command being used as
input for the next UNIX command). Here is an example:

# locate the tape drives that are available, and grab the device name
from the listed info
# the device name is listed in field 1 (end of field 1 is delimited by
a space)
lsdev -Cctape |grep Available|cut -f1 -d ' '|read TAPE_DRV
echo "The default available tape drive is /dev/${TAPE_DRV}"

Note that you can also use the system manager interface tool (smit) to
do many tasks on the system (perhaps not an FTP transfer) and it logs
the activities to two files: smit.log and smit.script

There is also a debugger command (set -vx) that can be issued at the
beginning of a Korn shell script and it will show all the commands that
are issued in the script. It may be valid in Bourne and Cshell as well
- not sure.

Steve

ped...@gmail.com

unread,
Mar 22, 2006, 9:20:59 PM3/22/06
to
Others may disagree but if you are going to grow into Unix (AIX), I
would use perl now and forever. I've done Unix for 20 years. I can do
either quite well. The old way is to use awk, sed, grep, sh, blah blah
blah. Or you can use perl. It is distributed with AIX now. There are
tons of books. There is a service call CPAN that has huge repositories
of very sophisticated libraries.

The main reason in your case to use perl is it is all inclusive. It
will know how to do the ftp, sanity check the transfer, talk to the sql
commands, etc. It is sort of a big step but I think it will be time
well spent. (You still have to use cron to kick off the job but thats
easy.)

caseyjbr...@gmail.com

unread,
Mar 23, 2006, 1:30:11 PM3/23/06
to
Hi Stephen,

One thing to remember is that AS/400 (As far as my limited
understanding of that platform is..) is a combination database,
operating system and job control system.

AIX is only an operating system. There are tools like
qdaemon, cron, perl and ksh and other programs to help create and
customize the operating system. But none of these
is going to give you the job control package that you
are looking for without some heavy programming work.

I would suggest that you try and research other job control
programs that work on top of AIX. One that I have seen
used in my past projects is Control-M. It has a Server-Client
setup. It can be used across several different machines,
has extensive logging, etc. That may be too much
for your environment, but I am sure there are other
choices.

Good Luck with your Choice/Transition.

Casey

0 new messages