码迷,mamicode.com
首页 > 其他好文 > 详细

centos7设置服务为开机自启动(以crond.serivce为例)

时间:2017-07-29 16:47:23      阅读:451      评论:0      收藏:0      [点我收藏+]

标签:ppi   scheduler   nts   job   stopped   org   end   centos7   symlink   

一、设置crond.service服务为开机自启动

步骤1:查看crond.serivce服务的自启动状态

[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl is-enabled crond.service
disabled
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 

此时crond.serivce的自启动状态为disabled

步骤2:开启crond.serivce服务自启动

[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl enable crond.service
Created symlink from /etc/systemd/system/multi-user.target.wants/crond.service to /usr/lib/systemd/system/crond.service.
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl is-enabled crond.service
enabled
[root@test_jenkins ~]#
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl list-unit-files | grep enable
abrt-ccpp.service                             enabled 
abrt-oops.service                             enabled 
abrt-vmcore.service                           enabled 
abrt-xorg.service                             enabled 
abrtd.service                                 enabled 
auditd.service                                enabled 
autovt@.service                               enabled 
crond.service                                 enabled 
dbus-org.freedesktop.NetworkManager.service   enabled 
dbus-org.freedesktop.nm-dispatcher.service    enabled 
getty@.service                                enabled 
irqbalance.service                            enabled 
lvm2-monitor.service                          enabled 
microcode.service                             enabled 
NetworkManager-dispatcher.service             enabled 
NetworkManager.service                        enabled 
ntpd.service                                  enabled 
postfix.service                               enabled 
rsyslog.service                               enabled 
snmpd.service                                 enabled 
sshd.service                                  enabled 
systemd-readahead-collect.service             enabled 
systemd-readahead-drop.service                enabled 
systemd-readahead-replay.service              enabled 
tuned.service                                 enabled 
xinetd.service                                enabled 
dm-event.socket                               enabled 
lvm2-lvmetad.socket                           enabled 
lvm2-lvmpolld.socket                          enabled 
pcscd.socket                                  enabled 
telnet.socket                                 enabled 
default.target                                enabled 
multi-user.target                             enabled 
remote-fs.target                              enabled 
runlevel2.target                              enabled 
runlevel3.target                              enabled 
runlevel4.target                              enabled 

此时crond.serivce的自启动状态为enabled

附:关闭crond.serivce的自启动状态

[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl disable crond.service
Removed symlink /etc/systemd/system/multi-user.target.wants/crond.service.
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl is-enabled crond.service
disabled
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 

二、开启和关闭crond.service服务

步骤1:查看crond.service的启动状态

[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 六 2017-07-29 14:19:12 CST; 5s ago
  Process: 805 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=0/SUCCESS)
 Main PID: 805 (code=exited, status=0/SUCCESS)

7月 28 14:23:31 test_jenkins systemd[1]: Started Command Scheduler.
7月 28 14:23:31 test_jenkins systemd[1]: Starting Command Scheduler...
7月 28 14:23:31 test_jenkins crond[805]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 84% if used.)
7月 28 14:23:31 test_jenkins crond[805]: (CRON) INFO (running with inotify support)
7月 29 14:19:12 test_jenkins systemd[1]: Stopping Command Scheduler...
7月 29 14:19:12 test_jenkins systemd[1]: Stopped Command Scheduler.
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 

此处显示crond.service的启动状态为dead

步骤2:开启服务

[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl start crond.service
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 

再次查看crond.service的启动状态

[root@test_jenkins ~]# 
[root@test_jenkins ~]# 
[root@test_jenkins ~]# systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2017-07-29 14:19:56 CST; 3s ago
 Main PID: 8465 (crond)
   CGroup: /system.slice/crond.service
           └─8465 /usr/sbin/crond -n

7月 29 14:19:56 test_jenkins systemd[1]: Started Command Scheduler.
7月 29 14:19:56 test_jenkins systemd[1]: Starting Command Scheduler...
7月 29 14:19:56 test_jenkins crond[8465]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 44% if used.)
7月 29 14:19:56 test_jenkins crond[8465]: (CRON) INFO (running with inotify support)
7月 29 14:19:56 test_jenkins crond[8465]: (CRON) INFO (@reboot jobs will be run at computers startup.)
[root@test_jenkins ~]# 
[root@test_jenkins ~]# 

此处显示crond.service的启动状态为running

 

centos7设置服务为开机自启动(以crond.serivce为例)

标签:ppi   scheduler   nts   job   stopped   org   end   centos7   symlink   

原文地址:http://www.cnblogs.com/simple-man/p/7255920.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!