Ticket #135: Introduction to Systemd and Lab 2.1 Tasks - SupaHotBall/OE2-Group-D GitHub Wiki

Task

  • Lab 2.1 tasks completed and documented.
  • Relevant systemd commands documented for service management.
  • Team collaboration (if applicable) confirmed and documented.

Steps Taken

Logging into server and running pstree command

image

Running command systemctl list-unit-files --type=target

image

Creating the shell script hello.sh using the code below


#!/bin/bash
while $(sleep 30);
do
    echo "Hello, systemd world"
done

image

Make the file executable using the command sudo chmod +x ~/hello.sh

image

Create unit file named hello.service in /etc/systemd/system using the code below


[Unit]
Description=Hello world service
After=systemd-user-sessions.service

[Service]
SyslogIdentifier=HelloWorldService
Type=simple
ExecStart=/home/$(whoami)/hello.sh

image

Verifying that systemd recognizes the unit which was created, using the command systemctl list-unit-files | grep hello.service

image

Starting the service using the command systemctl start hello.service

image

Check the service is running using the command systemctl status hello.service

image

See the logged output using the command journalctl -u hello -e

image


Challenges

The service failed to start initially because the execstart line in the hello.service file had the incorrect path. After changing to the correct path, the service started.


External Resources

N/A


Ticket Reference

https://rt.dataraster.com/Ticket/Display.html?id=135