[linux] How to install crontab on 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

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

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

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

grep on cron shows:

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

starting cron service returns:

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

This question is related to linux cron centos crontab

The answer is


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

yum install vixie-cron

And then start it with:

service crond start

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

chkconfig crond on

On CentOS 7 you need to use cronie:

yum install cronie

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

yum install vixie-cron

and

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)

Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to cron

How to run a cron job inside a docker container? Run CRON job everyday at specific time How to run a cron job on every Monday, Wednesday and Friday? Spring cron expression for every day 1:01:am How to run a cronjob every X minutes? CronJob not running Scheduling Python Script to run every hour accurately How to set a cron job to run every 3 hours Execute PHP script in cron job How to create a Java cron job

Examples related to centos

How to uninstall an older PHP version from centOS7 Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details pip install - locale.Error: unsupported locale setting ssh : Permission denied (publickey,gssapi-with-mic) How to change the MySQL root account password on CentOS7? Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 ffprobe or avprobe not found. Please install one How to check all versions of python installed on osx and centos Cannot find java. Please use the --jdkhome switch VirtualBox: mount.vboxsf: mounting failed with the error: No such device

Examples related to crontab

Run CRON job everyday at specific time How to set a cron job to run every 3 hours mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab How to install crontab on Centos Running a simple shell script as a cronjob Crontab Day of the Week syntax How to run crontab job every week on Sunday Running a cron job at 2:30 AM everyday How to specify in crontab by what user to run script? Using crontab to execute script every minute and another every 24 hours