Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use systemctl in Ubuntu 14.04

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?

like image 696
DenCowboy Avatar asked May 25 '16 13:05

DenCowboy


People also ask

How do I enable Systemctl in Linux?

To tell systemd to start services automatically at boot, you must enable them. To start a service at boot, use the enable command: sudo systemctl enable application . service.


2 Answers

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

like image 65
rjb-dev Avatar answered Sep 24 '22 17:09

rjb-dev


Ubuntu 14 and lower does not have "systemctl" Source: https://docs.docker.com/install/linux/linux-postinstall/#configure-docker-to-start-on-boot

Configure Docker to start on boot:

Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. Ubuntu 14.10 and below use upstart.

1) systemd (Ubuntu 16 and above):

$ sudo systemctl enable docker 

To disable this behavior, use disable instead.

$ sudo systemctl disable docker 

2) upstart (Ubuntu 14 and below):

Docker is automatically configured to start on boot using upstart. To disable this behavior, use the following command:

$ echo manual | sudo tee /etc/init/docker.override chkconfig  $ sudo chkconfig docker on 

Done.

like image 35
Dung Avatar answered Sep 25 '22 17:09

Dung