I created a test service under /etc/systemd/system which is the correct path to create custom unit files.
[root@apollo system]# cat sample.service [Unit] Description=This is my test service Wants=chronyd.service After=chronyd.service [Service] Type=forking ExecStart=/root/sample.sh [Install] WantedBy=multiuser.target chronyd.service #RequiredBy=multiuser.target chronyd.service #Alias=xyz [root@apollo system]# pwd /etc/systemd/system [root@apollo system]#
I made sure systemd is aware by running "systemctl daemon-reload". I was also able to stop/start the service.
When I tried to mask it, it shows me this error:
[root@apollo system]# systemctl mask sample.service Failed to execute operation: File exists [root@apollo system]#
That is because systemd is trying to create a symlink using this command:
ln -s /dev/null /etc/systemd/system/sample.service
Since sample.service already exists inside /etc/systemd/system, the command will fail unless systemd will use "ln -fs".
So meaning we cannot mask any unit files we create under /etc/systemd/system?
I tried to move sample.service to /usr/lib/systemd/system and I was able to mask it because it was able to create a symlink under /etc/systemd/system without any hindrance.
Has anybody experience this? Do you think this is a bug?