How to use systemctl in Ubuntu 14.04

DenCowboy picture DenCowboy · May 25, 2016 · Viewed 154.2k times · Source

I try to perform the following command in Ubuntu 14.04:

systemctl enable --now docker-cleanup-dangling-images.timer

I also tried it with sudo, I tried to replace systemctl with service and systemd but nothing works

sudo: systemd: command not found
systemd: command not found
sudo: service: command not foud

How can I execute this command in Ubuntu 14.04 or is there another way to execute the same command?

Answer

rjb-dev picture rjb-dev · Jul 7, 2016

I just encountered this problem myself and found that Ubuntu 14.04 uses Upstart instead of Systemd, so systemctl commands will not work. This changed in 15.04, so one way around this would be to update your ubuntu install.

If this is not an option for you (it's not for me right now), you need to find the Upstart command that does what you need to do.

For enable, the generic looks to be the following:

update-rc.d <service> enable

Link to Ubuntu documentation: https://wiki.ubuntu.com/SystemdForUpstartUsers