28

I want to debug/test a program in eclipse that uses a Redis server so I decided to turn the server into a user service to have the privilege of running it. What bothers me is that I can start or stop the service but not enable/disable it.

The error I get is:

Failed to execute operation: No such file or directory

Original /usr/lib/systemd/system:

[Unit]
Description=Advanced key-value store
After=network.target

[Service]
User=arkos
ExecStart=/usr/bin/redis-server /etc/arkos/arkos-redis.conf
ExecStop=/usr/bin/redis-cli shutdown

[Install]
WantedBy=multi-user.target

Edited and moved to /usr/lib/systemd/user:

[Unit]
Description=Advanced key-value store

[Service]
ExecStart=/usr/bin/redis-server /etc/arkos/arkos-redis.conf
ExecStop=/usr/bin/redis-cli shutdown

[Install]
WantedBy=default.target

Systemctl status:

�� arkos-redis.service - Advanced key-value store
   Loaded: loaded (/usr/lib/systemd/user/arkos-redis.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2015-08-25 09:19:25 UTC; 1min 55s ago
  Process: 644 ExecStop=/usr/bin/redis-cli shutdown (code=exited, status=1/FAILURE)
 Main PID: 736 (redis-server)
   CGroup: /user.slice/user-1000.slice/[email protected]/arkos-redis.service
           ������736 /usr/bin/redis-server *:0                        

Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-.__.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._        _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-.__.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.471 # Server started, Redis version 3.0.3
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 * The server is now ready to accept connections at /tmp/arkos-redis.sock

Journalctl:

Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # You requested maxclients of 10000 requiring at least 10032 max file descrip
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # Redis can't set maximum open files to 10032 because of OS error: Operation 
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.470 # Current maximum open files is 4096. maxclients has been reduced to 4064 to 
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _.-``__ ''-._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: _.-``    `.  `_.  ''-._           Redis 3.0.3 (00000000/0) 64 bit
Aug 25 09:19:25 arkos-vagrant redis-server[736]: .-`` .-```.  ```\/    _.,_ ''-._
Aug 25 09:19:25 arkos-vagrant redis-server[736]: (    '      ,       .-`  | `,    )     Running in standalone mode
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-...-` __...-.``-._|'` _.-'|     Port: 0
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._   `._    /     _.-'    |     PID: 736
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._  `-./  _.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-._    `-.__.-'    _.-'_.-'|
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |           http://redis.io
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |`-._`-._    `-.__.-'    _.-'_.-'|
Aug 25 09:19:25 arkos-vagrant redis-server[736]: |    `-._`-._        _.-'_.-'    |
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-._`-.__.-'_.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._    `-.__.-'    _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-._        _.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: `-.__.-'
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.471 # Server started, Redis version 3.0.3
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING overcommit_memory is set to 0! Background save may fail under low m
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING you have Transparent Huge Pages (THP) support enabled in your kerne
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sy
Aug 25 09:19:25 arkos-vagrant redis-server[736]: 736:M 25 Aug 09:19:25.472 * The server is now ready to accept connections at /tmp/arkos-redis.sock
1
  • 3
    Have you ran systemctl daemon-reload after moving/editing the files ? Commented Aug 25, 2015 at 13:58

5 Answers 5

25

Symlink issue?

I had a similar error message when using symbolic links.

Apparently systemd doesn't follow symbolic links, the solution is simply to copy or move the file.

User service?

I believe that you need to add --user to the command line for units in user/:

sudo systemctl --user enable arkos-redis.service
5
  • 2
    Was also the symlink problem here.
    – cweiske
    Commented May 13, 2016 at 13:35
  • 2
    Interesting. It did follow the symlink when I started the service, but enable didn't Commented Aug 8, 2016 at 16:46
  • You're right the symlink didn't work. I ended up using a hard link instead. Commented Oct 23, 2018 at 21:01
  • 2
    Curious. I'm using a symlink because it lets me git-manage the service file as part of its project, and it's fine for starting and stopping, but not for enabling. Very strange limitation.
    – rosuav
    Commented Mar 13, 2019 at 15:56
  • 1
    Here begins the discussion about why to allow or not symlinks: bugzilla.redhat.com/show_bug.cgi?id=955379#c14
    – jgomo3
    Commented Mar 29, 2019 at 13:14
12

In my case, I was placing my systemd unit files directly under /etc/systemd/system/... folders. Moved them to /lib/systemd/system instead and that resolved the issue with systemctl enable/disable commands.

2
  • 2
    It's been a long time since I've had this problem, but I remember something like this being the solution.
    – Folaht
    Commented Oct 15, 2018 at 6:46
  • 1
    in mycase, i copied from lib to etc and it worked Commented Jun 25, 2019 at 18:14
3

Try:

  • sudo touch /etc/init.d/arkos-redis

I had the same problem. If that doesn't work:

  • sudo strace systemctl enable arkos-redis

Look for where the last failure occurs.

1
  • the strace command was immensely helpful in my case! Commented Jan 26, 2023 at 2:30
0

I've had the same issue on Fedora 29.

Replace: After=network.target
With: Requires=network.target

It is incredibly frustrating because the file is clearly there but nothing seems to want to see it. There is no failure from the systemd analyze either. It just shows as 'bad' under systemctl list-unit-files.

0

From my experience this has usually happened when the service is masked.

~]# systemctl status zabbix-agent
● zabbix-agent.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

~]# systemctl is-enabled zabbix-agent
masked

~]# ls -l /etc/systemd/system/zabbix-agent.service
lrwxrwxrwx. 1 root root    9 Feb 29  2020 zabbix-agent.service -> /dev/null

~]# systemctl unmask zabbix-agent
Removed symlink /etc/systemd/system/zabbix-agent.service.

~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

Once it is unmasked it can be enabled.

Hope this helps someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .