记一次宝塔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>

宝塔相关

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

相关推荐
封步宇AIGC11 分钟前
量化交易系统开发-实时行情自动化交易-3.4.1.2.A股交易数据
人工智能·python·机器学习·数据挖掘
何曾参静谧11 分钟前
「Py」Python基础篇 之 Python都可以做哪些自动化?
开发语言·python·自动化
Prejudices15 分钟前
C++如何调用Python脚本
开发语言·c++·python
我狠狠地刷刷刷刷刷28 分钟前
中文分词模拟器
开发语言·python·算法
Jam-Young41 分钟前
Python的装饰器
开发语言·python
Mr.咕咕1 小时前
Django 搭建数据管理web——商品管理
前端·python·django
AnFany1 小时前
LeetCode【0028】找出字符串中第一个匹配项的下标
python·算法·leetcode·字符串·kmp·字符串匹配
爪哇学长2 小时前
Java API类与接口:日期类型与集合的使用
java·开发语言·python
封步宇AIGC2 小时前
量化交易系统开发-实时行情自动化交易-3.4.1.6.A股宏观经济数据
人工智能·python·机器学习·数据挖掘