Scripts & Special Files

background script

Last Revised: 12/18/22

This script may be used whenever it is necessary to start a background task with the same environment as a user who logs into a linux/Unix system.  It is typically executed during system boot, or by cron, at, or within a BBx application using CDS081, SCALL() or CDS180. Note that if you do not use this script to launch background tasks, calls to Dynamo Tools called programs will probably not work as they require a specific Dynamo Tools environment.

Arguments: background PGM CC TITLE { USR MODE LOGFILE EMAIL CONFIGBBX}

background
PGM This is the business basic program to be run.  Refer to the SMS Environment for the local and global variables that are set prior to running basic_pgm.  PGM should terminate with RUN "CDS001" to insure the information in the Display Terminal Status is updated.
CC Pass the two character company code, which will determine what Y.COMPCODE$ and other fields dependent on Y.COMPCODE$ will be set to.
TITLE This is a descriptive field, up to 40 characters in length, that will be displayed in Display System Status in the Dynaweb and Background Task section.  It can also be seen using the operating system ps -ef command.  Note the TITLE cannot contain any blanks, so use the underscore character in place of blanks.  They will be replaced with blanks automatically.
USR This is an optional argument for additional user information that will be passed to the PGM and referred to as ARGV(4).  If spaces are required, then enclose USR in quotes.
MODE The mode is an optional argument that is used to specify the executable to use and file open method.
null or not passedstart pro5 or bbj based on $BBXDIR
pro5pro5 with 4000 memory pages (1Mb)
numeric valuepro5 with the numeric value number of memory pages, minimum of 4000 is recommended to prevent out-of-memory errors
bbjbbj and use bbj for file access
bbjdsbbj, but use the local pro5 dataserver on the default port for all file opens. (/<localhost,port=1100>)
/<servername,port=portnumber>bbj to run PGM, but use a data server for file opens using the server name and port number specified.
LOGFILE

This optional argument is used to override the default log file of $SMSDIR/log/bkg.  Note that the original default log file of $SMSDIR/TEMP/BKGOUT is no longer used. On linux systems you can enable automated rotation of the log file by placing placing a file to the /etc/logrotate.d folder. The default log rotation file is shown below. This example log rotation configuration file is also available at $SMSDIR/bin/exa/dt_bkg.

 

/u/CDI/tmp/log/dt_bkg {
monthly
create 0666 cdi cdi
dateext
missingok
}

EMAIL This optional argument is used to override the default email address of support@excellware.com. An email is sent by the background script when it is unable to start pro5 or bbj.
CONFIGBBX Optional argument to override the default config file of $SMSDIR/CD/config/config.bbx.background.

The background task may use PRINT statements to log debugging or tracking information.  Any data printed will be appended to the logfile.  This file should be rotated using the appropriate operating system log rotation tools.  Do not use any mnemonics or cursor positioning expressions on any PRINT statement within the background task.

When using this script, you do not need to CALL "CDS011" within your PGM as it will be run automatically prior to running your PGM. However, at the end of the job, the application should either RUN "CDS001" or CALL "CDS081","",-1 to exit the application and not just RELEASE. This will update the System Activity Log and update the list of active processes shown in Display System Status.

Typical crontab entry that launches this background script with no USR field, using the default mode, logfile, email, and config file.
0 17 25 * * /u/CDI/bin/background SW080 DS Download_Ohio_Sales_Tax