开发者

How can I keep a RPG program running in memory?

开发者 https://www.devze.com 2023-01-20 16:05 出处:网络
I coded a monitoring program in RPG that checks if th开发者_开发问答e fax/400 is operational. And now I want this program to check every 15 minutes.

I coded a monitoring program in RPG that checks if th开发者_开发问答e fax/400 is operational.

And now I want this program to check every 15 minutes.

Instead of placing a job every 15 minutes in the job scheduler (which would be ugly to manage), I made the program wait between checks using DLYJOB.

Now how can I make this program "place itself" in memory so it keeps running?

(I thought of using SBMJOB, but I can't figure in which job queue I could place it.)


A good job queue to use for an endlessly running job would be QSYSNOMAX. That allows unlimited numbers of jobs to be running.

You could submit the job to that queue in your QSTRTUP program and it will simply remain running all the time.


Here what I have done in the past. There are two approaches to this.

  1. Submit a new job every time the program runs with DLYJOB before it runs.
  2. Create a loop and only end given a certain condition.

What I did with a Monitor MSGW program was the following:

         PGM     
         DCL        VAR(&TIME) TYPE(*CHAR) LEN(6)
         DCL        VAR(&STOPTIME) TYPE(*CHAR) LEN(6) +
                      VALUE('200000')   
         /* Setup my program (run only once) */
START:
         /* Perform my actions */

         RTVSYSVAL  SYSVAL(QTIME)  RTNVAR(&TIME)
         IF         COND(&TIME *GE &STOPTIME) THEN(GOTO CMDLBL(END))
         DLYJOB     DLY(180)
         GOTO       CMDLBL(START)
END:
         ENDPGM

This will run continuously until 8:00 pm. Then I add this to the job scheduler to submit every morning.

As far as which jobq. I am using QINTER, but it could really be run anywhere. Make sure you choose a subsystem with enough available running jobs as this will take one.

The negative of running in QINTER if the program starts to hit 100% CPU, that will use up all of your interactive CPU and effectively locks up your system.


i know of 3 ways to that.

1) using Data queue, there is parm to tell it to wait endlessly and at time-interval.
2) using OVRDBF cmd, there is parm there to tell that it should not end or EOF, making your pgm to keep on waiting.
3) easiest to implement, sbmjob to call a pgm that loops forever eg with DOW 1=1, you can insert a code to check for certain time interval before it iterates. You can have your logic inside the loop that checks for fax, process it and then back to waiting.

0

精彩评论

暂无评论...
验证码 换一张
取 消