Centos 7 memberikan perintah baru yaitu systemctl untuk melakukan manajemen service. Pada versi-versi sebelumnya untuk melakukan manajemen service kita menggunakan perintah service. Mulai Centos 7 ini diharapkan kita menggunakan perintah systemctl dan meninggalkan penggunaan perintah service maupun perintah chkconfig.

Berikut contoh-contoh

  1. Melakutan start sebuah service
    Untuk melakukan starting suatu service kita dapat menjalan perintah systemctl start name dengan contoh seperti berikut ini

    [root@localhost ~]# systemctl start httpd
    [root@localhost ~]#

  2. Melihat status service
    Untuk melihat status sebuah service kita dapat menjalankan perintah systemctl status nama seperti contoh berikut ini

    [root@localhost ~]# systemctl status httpd
    â httpd.service – The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Active: active (running) since Thu 2016-09-29 18:47:46 WIB; 2min 32s ago
    Docs: man:httpd(8)
    man:apachectl(8)
    Process: 11537 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
    Process: 6963 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
    Main PID: 11552 (httpd)
    Status: “Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec”
    CGroup: /system.slice/httpd.service
    ââ11552 /usr/sbin/httpd -DFOREGROUND
    ââ11553 /usr/sbin/httpd -DFOREGROUND
    ââ11554 /usr/sbin/httpd -DFOREGROUND
    ââ11555 /usr/sbin/httpd -DFOREGROUND
    ââ11556 /usr/sbin/httpd -DFOREGROUND
    ââ11557 /usr/sbin/httpd -DFOREGROUND

    Sep 29 18:47:46 localhost.localdomain systemd[1]: Starting The Apache HTTP Server…
    Sep 29 18:47:46 localhost.localdomain httpd[11552]: AH00558: httpd: Could not reliably determine the server’s fully …ssage
    Sep 29 18:47:46 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
    Hint: Some lines were ellipsized, use -l to show in full.

  3. Melakukan stop sebuah service
    Untuk melakukan stop sebuah service kita dapat menjalankan perintah systemctl stop nama seperti contoh berikut ini

    [root@localhost ~]# systemctl stop httpd
    [root@localhost ~]#

  4. Melakukan restart
    Untuk melakukan restart (stop dan start) sebuah service kita dapat menjalankan perintah systemctl restart nama seperti contoh berikut ini

    [root@localhost ~]# systemctl restart httpd
    [root@localhost ~]#

  5. Mereload konfigurasi service
    Kadang-kadang kita membuat perubahan sebuah konfigurasi suatu service dan kita ingin perubahan-perubahan itu diterapkan pada service tersebut. Untuk itu kita melakukan reload konfigurasi dengan systemctl reload nama seperti contoh berikut ini

    [root@localhost ~]# systemctl reload httpd
    [root@localhost ~]#

  6. Mengaktifkan saat boot
    Biasanya kita menginginkan service-service penting untuk langsung berjalan saat server Linux Centos 7 boot. Kita dapat melakukan enable pada service dengan perintah systemctl enable nama seperti contoh berikut ini

    [root@localhost ~]# systemctl enable httpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

  7. Tidak aktif saat boot
    Tentu tidak semua service selalu kita butuhkan. Untuk itu ada service-service yang tidak kita perlu start saat boot. Kita dapat mendisable saat boot dengan perintah systemctl disable name seperti contoh berikut ini

    [root@localhost ~]# systemctl disable httpd
    Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
    [root@localhost ~]#

Informasi lebih lanjut silahkan mengunjungi https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html.

Untuk perintah lama menggunakan service dan chkconfig seperti contoh berikut ini:
service iptables stop
chkconfig iptables off

Kunjungi www.proweb.co.id untuk menambah wawasan anda.

Perintah systemctl untuk manajemen service Centos 7
× Ada yang dapat saya bantu ? Available on SundayMondayTuesdayWednesdayThursdayFridaySaturday