Topic 9

Dates: 3/28/2018
Start-up and Run Levels. Scheduled jobs (at, cron)
Linux System Administration


Adding service to systemd startup

In directory /home/hostadm, create a shell script file, test.sh:

#!/bin/bash
echo current date/time is $(/bin/date) >> /home/hostadm/timecheck.txt

Make the script executable

chmod 755  /home/hostadm/test.sh

In directory /etc/systemd/system, create unit service file, test.service:

[Unit]
Description=test startup

[Service]
Type=simple
ExecStart=/home/hostadm/test.sh

[Install]
WantedBy=default.target

Enable service test in systemd:

systemctl daemon-reload
systemctl enable test

Run commands

systemctl start test
systemctl status test
Check if file /home/hostadm/timecheck.txt has been updated.
Reboot the VM. Run command

systemctl status test
Check if file /home/hostadm/timecheck.txt has been updated.



Take me to the Course Website