如何在 Centos 上安装 crontab [英] How to install crontab on Centos

查看:26
本文介绍了如何在 Centos 上安装 crontab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉在我的 centos 上使用 crontab -e 命令设置 cron 调度程序.但是今天我发现我的一个 centos 服务器没有这个命令

I am familiar to setup the cron scheduler using crontab -e command on my centos. But today I found one of my centos servers doesn't have this command

我尝试使用 yum install crontab 安装它,但没有成功.然后我尝试了 yum install crontabs 并安装了一些东西

I have tried to install this using yum install crontab but no luck. Then I tried yum install crontabs and it installed something

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Updating:
 crontabs                noarch     1.10-11.el5      base              7.0 k

Transaction Summary
=============================================================================
Install      0 Package(s)         
Update       1 Package(s)         
Remove       0 Package(s)         

Total download size: 7.0 k
Is this ok [y/N]:

但是 crontab 命令仍然不起作用.如果我执行 cat/etc/crontab 那么它会在下面显示

But still the crontab command doesn't work. If I do cat /etc/crontab then it shows below thing

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
40 * * * * root run-parts /etc/cron.hourly
54 1 * * * root run-parts /etc/cron.daily
14 3 * * 0 root run-parts /etc/cron.weekly
38 1 16 * * root run-parts /etc/cron.monthly

我应该怎么做才能在该特定服务器上安装 crontab?我正在使用 CentOS release 5.2 (Final).

What should I do to have crontab on that particular server? I am using CentOS release 5.2 (Final).

cron 上的 grep 显示:

grep on cron shows:

[root~]# ps -ef | grep cron
root     24022 24001  0 19:07 pts/1    00:00:00 grep cron

启动 cron 服务返回:

starting cron service returns:

[root~]# service cron start
cron: unrecognized service

推荐答案

在CentOS上安装crontab,CentOS中的crontab包是vixie-cron.因此,请安装:

As seen in Install crontab on CentOS, the crontab package in CentOS is vixie-cron. Hence, do install it with:

yum install vixie-cron

然后开始:

service crond start

要使其持久化,以便在启动时启动,请使用:

To make it persistent, so that it starts on boot, use:

chkconfig crond on

<小时>

在 CentOS 7 上你需要使用 cronie:

yum install cronie

在CentOS 6上可以安装vixie-cron,但真正的包是cronie:

On CentOS 6 you can install vixie-cron, but the real package is cronie:

yum install vixie-cron

yum install cronie

在这两种情况下,您都会得到相同的输出:

In both cases you get the same output:

.../...
==================================================================
 Package         Arch       Version         Repository      Size
==================================================================
Installing:
 cronie          x86_64     1.4.4-12.el6    base             73 k
Installing for dependencies:
 cronie-anacron  x86_64     1.4.4-12.el6    base             30 k
 crontabs        noarch     1.10-33.el6     base             10 k
 exim            x86_64     4.72-6.el6      epel            1.2 M

Transaction Summary
==================================================================
Install       4 Package(s)

这篇关于如何在 Centos 上安装 crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆