记一次宝塔centos出现Failed to start crond.service: Unit crond.service not found.解决

问题描述

我遇到的是执行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又正常

看效果
shell 复制代码
[xxxx@xxxx-centos ~]#systemctl status crond.service
● crond.service
   Loaded: not-found (Reason: Unit crond.service not found.)
   Active: failed (Result: resources) since Sat 2024-11-09 09:13:31 CST; 18min ago
 Main PID: 3588034 (code=exited, status=0/SUCCESS)
    Tasks: 42 (limit: 97394)
   Memory: 248.7M
   CGroup: /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_agent

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: 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 试了一下 果然成了这里贴出来供大家参考,效果如下:

shell 复制代码
[xxxx@xxxx-centos ~]# systemctl daemon-reload
[xxxx@xxxx-centos ~]# systemctl start crond.service
[xxxx@xxxx-centos ~]# systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: >
   Active: active (running) since Sat 2024-11-09 09:33:02 CST; 10s ago
 Main PID: 689058 (crond)
    Tasks: 45 (limit: 97394)
   Memory: 267.5M
   CGroup: /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_agent

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]: 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>

宝塔相关

我这边使用的是宝塔,即使上面这些都正常了在宝塔面板的计划任务顶部依然会出现检测到计划任务服务失败什么的,直接点后面的一键修复按钮,然后等待几分钟没报错就证明成了,(之前上面服务没修复时点一键修复,提示一堆修复失败)

相关推荐
大然Ryan19 分钟前
MCP实战:从零开始写基于 Python 的 MCP 服务(附源码)
python·llm·mcp
学不好python的小猫1 小时前
7-4 身份证号处理
开发语言·python·算法
MAOX7891 小时前
基于python的web系统界面登录
前端·python
一颗红心丶2 小时前
Windows系统上离线部署Python运行飞桨(PaddlePaddle) OCR服务
windows·python·paddlepaddle
我爱音乐yyy2 小时前
pythonday50
pytorch·python·深度学习
white.tie2 小时前
一个手机请求头的随机库
开发语言·javascript·python
Mikhail_G2 小时前
Python初学者入门指南
大数据·运维·开发语言·python·数据分析
和我乘风破浪3 小时前
iOS自动化录屏在Chrome浏览器打不开处理方法
python·测试
站大爷IP3 小时前
当生成器遇上异步IO:Python并发编程的十大实战兵法
python
大明者省3 小时前
pycharm2020.2版本给项目选择了虚拟环境解释器,项目文件都运行正常,为什么terminal文件路径的前面没有虚拟解释器的名称
开发语言·python