问题描述
我遇到的是执行systemctl start crond.service 就报错Failed to start crond.service: Unit crond.service not found.,执行systemctl status crond.service 又正常(虽然显示status里的服务是没启动的,但是status的功能是正常执行了),理论上如果crond.service不存在应该两个都报错,就很有迷惑性,看了网上很多人的说法众说纷纭,有说把systemctl目录带全执行start,有说字节重新start、有说卸载然后安装再start,在我这里都不凑效,依然三start报错status又正常
看效果
[xxxx@xxxx-centos ~]#systemctl status crond.service
● crond.serviceLoaded: not-found (Reason: Unit crond.service not found.)Active: failed (Result: resources) since Sat 2024-11-09 09:13:31 CST; 18min agoMain PID: 3588034 (code=exited, status=0/SUCCESS)Tasks: 42 (limit: 97394)Memory: 248.7MCGroup: /system.slice/crond.service├─ 215598 /usr/local/qcloud/YunJing/YDEyes/YDService├─ 215688 /usr/local/qcloud/YunJing/YDLive/YDLive├─ 396691 /usr/local/qcloud/stargate/bin/sgagent -d├─2059147 barad_agent├─2059148 barad_agent└─2059149 barad_agentNov 09 09:13:19 VM-0-5-centos systemd[1]: This usually indicates unclean terminati>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: crond.service: Found left-over process 2>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: This usually indicates unclean terminati>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: crond.service: Failed to load environmen>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: crond.service: Failed to run 'start' tas>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: crond.service: Failed with result 'resou>
Nov 09 09:13:19 VM-0-5-centos systemd[1]: Failed to start Command Scheduler.
Nov 09 09:13:31 VM-0-5-centos systemd[1]: crond.service: Service RestartSec=100ms >
Nov 09 09:13:31 VM-0-5-centos systemd[1]: crond.service: Failed to schedule restar>
Nov 09 09:13:31 VM-0-5-centos systemd[1]: crond.service: Failed with result 'resou>
[xxxx@xxxx-centos ~]#systemctl start crond.service
Failed to start crond.service: Unit crond.service not found.
搞了老半天,网络上的解决方案全都试了一遍,完全不行,再三思考额如果status能成就证明文件肯定存在(忘记service所在目录了没去考证),那也就是说start有问题咯,又想到好像之前有用到郭很多次systemctl有一个重新加载的功能, systemctl daemon-reload 试了一下 果然成了这里贴出来供大家参考,效果如下:
[xxxx@xxxx-centos ~]# systemctl daemon-reload
[xxxx@xxxx-centos ~]# systemctl start crond.service
[xxxx@xxxx-centos ~]# systemctl status crond.service
● crond.service - Command SchedulerLoaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: >Active: active (running) since Sat 2024-11-09 09:33:02 CST; 10s agoMain PID: 689058 (crond)Tasks: 45 (limit: 97394)Memory: 267.5MCGroup: /system.slice/crond.service├─ 215598 /usr/local/qcloud/YunJing/YDEyes/YDService├─ 215688 /usr/local/qcloud/YunJing/YDLive/YDLive├─ 396691 /usr/local/qcloud/stargate/bin/sgagent -d├─ 689058 /usr/sbin/crond -n├─2059147 barad_agent├─2059148 barad_agent└─2059149 barad_agentNov 09 09:33:02 VM-0-5-centos systemd[1]: This usually indicates unclean terminati>
Nov 09 09:33:02 VM-0-5-centos systemd[1]: crond.service: Found left-over process 2>
Nov 09 09:33:02 VM-0-5-centos systemd[1]: This usually indicates unclean terminati>
Nov 09 09:33:02 VM-0-5-centos systemd[1]: crond.service: Found left-over process 2>
Nov 09 09:33:02 VM-0-5-centos systemd[1]: This usually indicates unclean terminati>
Nov 09 09:33:02 VM-0-5-centos systemd[1]: Started Command Scheduler.
Nov 09 09:33:02 VM-0-5-centos crond[689058]: (CRON) STARTUP (1.5.2)
Nov 09 09:33:02 VM-0-5-centos crond[689058]: (CRON) INFO (RANDOM_DELAY will be sca>
Nov 09 09:33:02 VM-0-5-centos crond[689058]: (CRON) INFO (running with inotify sup>
Nov 09 09:33:02 VM-0-5-centos crond[689058]: (CRON) INFO (@reboot jobs will be run>
宝塔相关
我这边使用的是宝塔,即使上面这些都正常了在宝塔面板的计划任务顶部依然会出现检测到计划任务服务失败什么的,直接点后面的一键修复按钮,然后等待几分钟没报错就证明成了,(之前上面服务没修复时点一键修复,提示一堆修复失败)