一、设置crond.service服务为开机自启动
步骤1:查看crond.serivce服务的自启动状态
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl is-enabled crond.service disabled [[email protected]_jenkins ~]# [[email protected]_jenkins ~]#
此时crond.serivce的自启动状态为disabled
步骤2:开启crond.serivce服务自启动
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl enable crond.service Created symlink from /etc/systemd/system/multi-user.target.wants/crond.service to /usr/lib/systemd/system/crond.service. [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl is-enabled crond.service enabled [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_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 [email protected] enabled crond.service enabled dbus-org.freedesktop.NetworkManager.service enabled dbus-org.freedesktop.nm-dispatcher.service enabled getty[email protected] 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的自启动状态
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl disable crond.service Removed symlink /etc/systemd/system/multi-user.target.wants/crond.service. [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl is-enabled crond.service disabled [[email protected]_jenkins ~]# [[email protected]_jenkins ~]#
二、开启和关闭crond.service服务
步骤1:查看crond.service的启动状态
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_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. [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]#
此处显示crond.service的启动状态为dead
步骤2:开启服务
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# systemctl start crond.service [[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_jenkins ~]#
再次查看crond.service的启动状态
[[email protected]_jenkins ~]# [[email protected]_jenkins ~]# [[email protected]_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 computer‘s startup.) [[email protected]_jenkins ~]# [[email protected]_jenkins ~]#
此处显示crond.service的启动状态为running
时间: 2024-10-08 10:21:43