Ticket ID #132 ‐ Introduction to Systemd and Lab 2.1 Tasks - GriffinKat/group-a GitHub Wiki

Turn bash scripts into systemd service files

  1. Create a shell script in your home directory

{64AC7098-9AD7-4C33-BC53-C231EEE8C796}

  1. Make the file executable

{FD923EC7-49F2-4027-A98C-3BD974F78723}

  1. When executing the file I found it was taking too long so I changed the sleep to 5

{59E23B5E-E231-47C5-AA19-DC8E943779D6}

Here you can see it is running

{9C6B2BE8-C2CB-4F65-9DB3-600EBA54460F}

  1. Create a service file for the hello.sh script

{CEE951C5-2274-4540-85DA-6AEE96736122}

{DD9C62CE-64B7-4C9F-BA91-7D85D341F5F8}

  1. Copy this le to /etc/systemd/system

{3C09A706-2605-4050-A5C3-F643734E414C}

  1. Start the new service with the command

systemctl start hello.service

{31774EDF-7F5E-41AC-B568-6B88A399C150}

  1. Check that it is running with the command

systemctl status hello.service

{85EB5D69-FBCE-405F-9690-3D1F83AE69E6}

  1. Stop the service from running with the command

systemctl stop hello.service

{50FC4D6A-4BA4-45A8-B29A-642D7BE6339A}

  1. Verify that it has stopped with the command

systemctl status hello.service

{B7E609A5-C650-4FFF-B290-5A0124AAD3CB}