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
Running command systemctl list-unit-files --type=target
Creating the shell script hello.sh using the code below
#!/bin/bash
while $(sleep 30);
do
echo "Hello, systemd world"
done
Make the file executable using the command sudo chmod +x ~/hello.sh
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
Verifying that systemd recognizes the unit which was created, using the command systemctl list-unit-files | grep hello.service
Starting the service using the command systemctl start hello.service
Check the service is running using the command systemctl status hello.service
See the logged output using the command journalctl -u hello -e
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