2

My operating system is Ubuntu Bionic beaver.

I have written a systemd serivce unit:

/etc/systemd/user# ll
total 20
drwxrw-r-x 2 rock64 rock64 4096 Nov 23 15:06 ./
drwxr-xr-x 5 root   root   4096 Nov 20 07:21 ../
-rw-r--r-- 1 rock64 rock64   74 Nov 23 14:30 photon_uploader.env
-rwxr-xr-x 1 rock64 rock64  463 Nov 23 14:50 photon_uploader.service*
-rw-r--r-- 1 rock64 rock64  175 Nov 23 14:57 photon_uploader.socket

but if I try enabling it I get error:

 systemctl enable photon_uploader
Failed to enable unit: Unit file photon_uploader.service does not exist.

I couldnt think of where to systematically put the service file , so I put it under user folder, and since I install service from a remote location , I rsync, and I have given the user folder ownership to non-root user. I

Ciasto piekarz
  • 228
  • 3
  • 12

1 Answers1

1

For my userspace systemd service, I put my files in $HOME/.config/systemd/user. Then, I ran systemctl enable --user my_service.

ajgringo619
  • 3,113
  • 1
  • 11
  • 37
  • well I created a symlink of `photon_uploader.service` in `/etc/systemd/system` from `/etc/systemd/user/photon_uploader.service` then I did `systemctl daemon-reload` and enabled it, and started it worked. But when I disabled it and try to reenable it, I again got error, service not found, so I had to manually create the symlink again. – Ciasto piekarz Nov 23 '19 at 17:44
  • If you move your files to the directory I posted, you won't need to use symlinks. – ajgringo619 Nov 23 '19 at 18:05
  • gives me permission denied error while trying to rsync – Ciasto piekarz Nov 23 '19 at 18:10
  • Run `mkdir -p $HOME/.config/systemd/user; mv /etc/systemd/user/* $HOME/.config/systemd/user`, then `systemctl enable --user photon_uploader`. – ajgringo619 Nov 23 '19 at 18:13
  • didnt worked . the `systemd` fodler in `$HOME/.config` didnt existed so I created it. but I got error `Failed to enable unit: Unit file photon_uploader.service does not exist.` – Ciasto piekarz Nov 23 '19 at 18:16
  • What does `ls -l $HOME/.config/systemd/user` show? – ajgringo619 Nov 23 '19 at 18:19
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/101409/discussion-between-ajgringo619-and-ciasto-piekarz). – ajgringo619 Nov 23 '19 at 18:20
  • `$ ls systemd/user/ multi-user.target.wants photon_uploader.env photon_uploader.service photon_uploader.socket` – Ciasto piekarz Nov 23 '19 at 18:20