Cron 服务启动失败

Cron 服务启动失败

我有一台 Ubuntu 14.04,我试图启动 cron 服务,但没有成功。运行后我总是得到这个service cron start

cron.service 的作业失败,因为控制进程退出并出现错误代码。

systemctl status cron.service说 cron 服务已加载但失败了:

cron.service
   Loaded: loaded (/etc/init.d/cron; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-06-15 09:06:19 AWST; 6min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 22707 ExecStart=/etc/init.d/cron start (code=exited, status=1/FAILURE)

 cron[22707]: Rather than invoking init scripts through /etc/init.d, use the service(8)
 cron[22707]: utility, e.g. service cron start
 cron[22707]: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
 cron[22707]: Since the script you are attempting to invoke has been converted to an
 cron[22707]: Upstart job, you may also use the start(8) utility, e.g. start cron
 cron[22707]: start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
 systemd[1]: cron.service: Control process exited, code=exited status=1
 systemd[1]: Failed to start cron.service.
 systemd[1]: cron.service: Unit entered failed state.
 systemd[1]: cron.service: Failed with result 'exit-code'.

关于如何使 cron 服务成功启动有什么提示吗?

答案1

如果 cron 服务未处于活动状态、失败或尝试重新启动,则终止它应该不成问题。请按照以下步骤操作:

使用以下方法杀死它:

pkill -f crond

使用以下方式启动它:

systemctl start crond

检查 crond 状态:

systemctl status cron.service

答案2

我遇到了类似的问题,这就是我所看到的

 systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-02-07 13:34:38 EST; 2min 37s ago
  Process: 31470 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=1/FAILURE)
 Main PID: 31470 (code=exited, status=1/FAILURE)

我通过检查我的 cron 日志来解决这个问题。我在 rhel 中运行,我的日志位于 /var/log/cron,我的问题是由于这个...(CRON) DEATH(无法锁定 /var/run/crond.pid,其他 pid 可能是 31364):资源暂时不可用

所以我刚才

pkill -f crond

然后

systemctl start crond.service 

然后就恢复正常了

systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-02-07 13:37:19 EST; 1s ago
 Main PID: 31490 (crond)
   CGroup: /system.slice/crond.service
           └─31490 /usr/sbin/crond -n

相关内容