วันพุธที่ 7 มิถุนายน พ.ศ. 2560

คำสั่งจัดการ Service Linux CentOS7 ด้วย Systemd


คำสั่งการใช้งานของ Systemd โดยมีรายละเอียดคำสั่งคร่าวๆ ดังนี้ 
การตรวจสอบรายชื่อบริการ (List all running services ) 
# systemctl

การเปิดบริการ (Activates a service) 
# systemctl start service_name 
ตัวอย่าง เช่น
# systemctl start httpd
การปิดบริการ (Deactivates a service) 
# systemctl stop service_name 
ตัวอย่าง เช่น
# systemctl stop httpd 
# systemctl stop iptables 
# systemctl stop ip6tables
การปรับใช้งานบริการใหม่ (Reload a service) 
* ใช้ในกรณีหลังการปรับแต่งค่าบริการหรือ config file โดยไม่ให้รบกวนบริการที่กำลังทำงานอยู่ 
# systemctl reload service_name 
ตัวอย่าง เช่น
# systemctl reload httpd
การเรียกใช้งานบริการใหม่ (Restarts a service) 
# systemctl restart service_name 
ตัวอย่าง เช่น
# systemctl restart httpd
การเริ่มบริการที่มีอยู่แล้วให้ทำงานใหม่ (Restarts if the service is already running) 
# systemctl condrestart service_name 
ตัวอย่าง เช่น
systemctl condrestart httpd
การตรวจสอบดูสถานะของบริการ (Shows status of a service) 
# systemctl status service_name 
ตัวอย่าง เช่น
# systemctl status httpd 
# systemctl status iptables
การเปิดใช้งานบริการตอนบู๊ตระบบ 
การเปิดบริการตอนบู๊ตเครื่อง (Enables a service to be started on bootup)
# systemctl enable service_name 
ตัวอย่าง เช่น
# systemctl enable httpd
การปิดบริการตอนบู๊ตเครื่อง (Disables a service to not start during bootup) 
# systemctl disable service_name 
ตัวอย่าง เช่น
systemctl disable httpd
การเปิดบริการแบบ Manual (masked) 
# systemctl mask service_name 
ตัวอย่าง เช่น
# systemctl mask dovecot
การตรวจสอบว่าบริการที่มีอยู่ถูกเปิดใช้งานอยู่หรือไม่ 
# systemctl is-enabled service_name 
หรือ
# systemctl is-enabled service_name; echo $?
โดยที่
0 มีการเปิดใช้งาน
1 มีการปิดการใช้งาน
ตัวอย่าง เช่น
# systemctl is-enabled httpd 
masked
# systemctl is-enabled httpd ; echo $?
masked
1
เปรียบเทียบคำสั่ง CentOS 6.x down vs CentOS 7.x up 
service service_name start = systemctl start service_name 
service service_name stop = systemctl stop service_name 
service service_name restart = systemctl restart service_name 
service service_name reload = systemctl reload service_name 
service service_name status = systemctl status service_name 
chkconfig service_name on = systemctl enable service_name 
chkconfig service_name off = systemctl disable service_name 
chkconfig --list service_name = systemctl is-enabled service_name 
chkconfig --list = systemctl list-unit-files --type=service
--


Load disqus comments

0 ความคิดเห็น