Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep a RPG program running in memory?

I coded a monitoring program in RPG that checks if the 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.)

like image 624
Danny T. Avatar asked Dec 29 '25 11:12

Danny T.


2 Answers

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.

like image 110
David G Avatar answered Jan 01 '26 16:01

David G


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.

like image 44
Mike Wills Avatar answered Jan 01 '26 18:01

Mike Wills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!