Skip to content

Latest commit

 

History

History
99 lines (82 loc) · 3.27 KB

HANDS_ON.md

File metadata and controls

99 lines (82 loc) · 3.27 KB
title nav_exclude
Hands-on Exercise
true

Introductory (hands-on) Exercise

In this exercise, you will define a simple "service" and manage it with the Service Commander. For demonstrative purposes, the "service" is just a simple script that doesn't do anything besides produce output.

Naturally, this exercise requires you to install sc first.

1. Create a simple program (shell script)

To create a sample "service", open an SSH terminal, 'cd' to a directory of your choice, and run the following commands.

echo '#!/QOpenSys/pkgs/bin/bash' > myscript.sh
echo 'echo starting' > myscript.sh
echo 'while :; do sleep 5 && echo running ;done' >> myscript.sh
chmod +x ./myscript.sh

As you can see, this "service" does nothing more than periodically produce output. If you'd like to, you may run ./myscript.sh to see what it does (<ctrl>+c to exit).

2. Use the scinit utility to make a service definition

From your SSH session, run:

scinit ./myscript.sh

Answer the questions like so:

image

The tool should also show you the information about the service you just created image

3. Start the service

Since the short name of the service is myscript, you can start your newly-created service by running:

sc start myscript

4. Observe the service running in WRKACTJOB

From a 5250 session, run

WRKACTJOB JOB(MYSCRIPT)

Observe the jobs that are now running under the 'myscript' job name you provided earlier. image

5. Display the service log file

From an SSH terminal, run:

sc loginfo myscript

This will give you a command that can be run to monitor the log file.

myscript: tail -f /home/JGORZINS/.sc/logs/2021-05-19-12.05.38.myscript.log

In this case, it will be a tail -f command. Copy/paste that command to watch the log file. image

Press <ctrl>+c to stop watching the log file

6. Stop the service

From your SSH session, run:

sc stop myscript

7. Clear your logs directory

rm $HOME/.sc/logs/*

8. Start the service again (this time with --splf)

sc --splf start myscript

9. View performance info

sc perfinfo myscript

10. Display the log file

sc loginfo myscript

Note that this time, it will give you a DSPSPLF command. This is because you started the service with the --splf option. Unfortunately, you cannot view this file while it is still open by the job. So, copy the DSPSPLF command, stop the service by running:

sc stop myscript

and then run the DSPSPLF command in 5250 to view the spooled file

12. Delete the service definition

View the information about the service by running:

sc info myscrpt

Part of the output will show you what file the service is defined in. You can delete the service definition by simply deleting the YAML file.