vim /home/mytest.sh rm -f /home/mytest/*
I want to write a service to execute the remove action.
sudo systemctl stop mytest can delete files in /home/mytest
sudo systemctl start mytest do nothing.
Edit my service file.
sudo vim /etc/systemd/system/mytest.service [Unit] Description=delete file [Service] Type=oneshot ExecStart=/bin/true ExecStop=/bin/bash /home/mytest.sh [Install] WantedBy=multi-user.target
sudo systemctl enable mytest
Now i found a strange action for mytest service.
sudo systemctl start mytest can delete files in /home/mytest
sudo systemctl stop mytest do nothing.
Why? Pleas give a explanation in detail.