Hello,
I intend execute a script everytime my system shutdown. To do this I followed this article (I don't know if it is the best option): https://www.golinuxcloud.com/run-scr...hutdown-linux/
After I ran the command "$ systemctl enable /etc/systemd/system/works.service" I received this message:
Code:
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
My script is:
Code:
-rwxrwxr-x 1 user user 148 may 8 4:11 Desktop/work.sh
and my file in /etc/systemd/system/ is:
Code:
-rwxr-xr-x 1 root root 216 may 8 4:12 /etc/systemd/system/works.service
and
Code:
$ cat /etc/systemd/system/works.service
[UNIT]
Description=Run my custom task at shutdown
DefaultDependencies=no
Before=shutdown.target
[SERVICE]
Type=oneshot
ExecStart=/home/user/Desktop/work.sh
TimeoutStartSec=0
[INSTALL]
WantedBy=shutdown.target
What kind configuration can I try or what am I doing wrong?
Thank you