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

宝塔相关

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

相关推荐
编程修仙1 小时前
Collections工具类
linux·windows·python
芝麻团坚果1 小时前
对subprocess启动的子进程使用VSCode python debugger
linux·ide·python·subprocess·vscode debugger
EterNity_TiMe_1 小时前
【论文复现】神经网络的公式推导与代码实现
人工智能·python·深度学习·神经网络·数据分析·特征分析
Stara05112 小时前
Git推送+拉去+uwsgi+Nginx服务器部署项目
git·python·mysql·nginx·gitee·github·uwsgi
hence..2 小时前
Vscode写markdown快速插入python代码
ide·vscode·python
DanielYQ3 小时前
LCR 001 两数相除
开发语言·python·算法
vener_3 小时前
LuckySheet协同编辑后端示例(Django+Channel,Websocket通信)
javascript·后端·python·websocket·django·luckysheet
封步宇AIGC4 小时前
量化交易系统开发-实时行情自动化交易-4.2.3.指数移动平均线实现
人工智能·python·机器学习·数据挖掘
互联网杂货铺4 小时前
自动化测试基础知识总结
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
小汤猿人类4 小时前
SpringTask
开发语言·python