LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Cron Not Working on CentOS (https://www.linuxquestions.org/questions/linux-server-73/cron-not-working-on-centos-921839/)

carlosinfl 01-03-2012 02:19 PM

Cron Not Working on CentOS
 
I've got a LAMP server running CentOS 5.7 & noticed a script I had in /etc/cron.hourly wasn't being ran. I checked /var/log/cron and it's completely empty:

Code:

[root@lamp]# ls -la /var/log/cron
-rw------- 1 root root 0 Jun 23 2010 /var/log/cron

So I don't think I have the correct packages installed for cron.

I searched my systems for all installed packages with the name "cron" in it:

Code:

[root@lamp:~]# rpm -qa | grep -i "cron"
crontabs-1.10-8

That's all that came up. Am I missing something? There's no startup / shutdown scripts in /etc/init.d/ either. Any ideas what I'm missing?

kbscores 01-03-2012 02:32 PM

crontabs is the only file you need.

Try running crontab -l

if it doesn't come up than it didn't get saved -- I reccommend using
Code:

crontab -e

0**** /path/command


Remember:


* * * * * Command to be executed
- - - - -
| | | | |
| | | | +----- Day of week (0-7)
| | | +------- Month (1 - 12)
| | +--------- Day of month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Min (0 - 59)

carlosinfl 01-03-2012 02:47 PM

I'm very confused...

I have the package 'crontabs' installed:

Code:

[root@lamp:~]# rpm -qa | grep -i "crontabs"
crontabs-1.10-8

But when I try and list / edit crontabs, I get the following:

Code:

[root@lamp:~]# crontab -l
-bash: crontab: command not found


anomie 01-03-2012 04:07 PM

Is the cron daemon running?

Code:

# pgrep crond
If not:
  1. Is it installed? You're looking for the vixie-cron package.
  2. Is the service started? (/etc/init.d/crond)

anomie 01-03-2012 04:08 PM

Quote:

Originally Posted by carlosinfl
Am I missing something? There's no startup / shutdown scripts in /etc/init.d/ either. Any ideas what I'm missing?

Just noticed this. There's nothing in /etc/init.d at all? (You're certainly missing something, if correct.)

sleddog 01-03-2012 04:22 PM

You don't have the cron daemon.

[root@server] yum install vixie-cron

Will fix you up.

carlosinfl 01-04-2012 10:16 AM

OK so I ran the command to install the package you suggested:

Code:

[root@lamp:~]# yum install vixie-cron

Running Transaction
  Installing    : vixie-cron                                                                                                                                                            1/1

Installed:
  vixie-cron.x86_64 4:4.1-77.el5_4.1

Now I can see the startup / shutdown script in /etc/init.d/

Code:

[root@lamp:~]# /etc/init.d/crond start
Starting crond:                                            [  OK  ]

Now how can I verify that the script '00awstats' that is stored in the /etc/cron.hourly/ directory is properly ran? Is there a way I can verify the script is running?

unSpawn 01-04-2012 12:48 PM

Quote:

Originally Posted by carlosinfl (Post 4565894)
how can I verify that the script '00awstats' (..) is properly ran? Is there a way I can verify the script is running?

How about just 'grep 00awstats /var/log/cron'?


All times are GMT -5. The time now is 06:15 AM.