title | nav_exclude |
---|---|
Hands-on Exercise |
true |
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.
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).
From your SSH session, run:
scinit ./myscript.sh
Answer the questions like so:
The tool should also show you the information about the service you just created
Since the short name of the service is myscript
, you can start your newly-created service by running:
sc start myscript
From a 5250 session, run
WRKACTJOB JOB(MYSCRIPT)
Observe the jobs that are now running under the 'myscript' job name you provided earlier.
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.
Press <ctrl>+c
to stop watching the log file
From your SSH session, run:
sc stop myscript
rm $HOME/.sc/logs/*
sc --splf start myscript
sc perfinfo myscript
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
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.