LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Cron not working after several tries (https://www.linuxquestions.org/questions/linux-server-73/cron-not-working-after-several-tries-4175515770/)

bulrush15 08-21-2014 05:17 AM

Cron not working after several tries
 
Redhadt RHEL 5.5.56 on a physical machine, not a virtual machine

Cron doesn't seem to be working. I have cron working on an Ubuntu box so I know the basics of cron, but cron does not seem to be working on the Redhat box. This is the first time I tried to use cron on this Redhat box.

- Email is not set up on this system at all so no chance of me getting error messages in email from cron. (I get error messages/output from cron in email on my Ubuntu box.)

If there is a mail package already installed, let me know what it is, I can try it. But this is a mission critical box, and if I install a package, and a single library changes, it can clobber the whole box and we are in deep shite. (I've had the occasional, but annoying problem with this on Windows.)



- I added my user to /etc/cron.allow. What other users have to be in cron.allow? Because it was blank when I edited it as root.

- Each line in my personal crontab ends with CR.

- I made a test script to run called 'gotest' which should put an entry in a log file every 2 minutes but nothing happens to the log file. I can run 'gotest' manually just fine and it puts an entry in my logfile in my home dir.

Could this be a permissions problem of the scripts cron is calling? My permissions of the script 'gotest' called in the crontab looks like this:

Code:

-rwxrwxrwx 1 chuck wheel 139 Aug 21 06:34 gotest*
The contents of gotest are this:

Code:

#!/bin/csh
set logfile=/export/home/comp/perl/foo/automail2014/logcron.txt
echo `date`, `whoami` ran $0 >> $logfile

Logfile permissions:
Code:

-rw-rw-rw- 1 chuck wheel  283 Aug 20 08:05 logcron.txt
- 'gotest' is supposed to run every 3 minutes. 'gocron' is supposed to run every 10 minutes. My personal crontab:

Code:

# Crontab file for user 'chuck'
# Aug 19, 2014
# Every line MUST end with CR.
# Fields: 1)Minutes, 2)Hour, 3)Day of month 1-31, 4)Month 1-2 5)Day of week 0 (sunday)-6 or names, 6)Command
MAIL=foo@bar.com
#MAIL=chuck
PATH=/usr/bin:/usr/sbin:/sbin:/bin
10 * * * * /export/home/comp/perl/foo/automail2014/gocron
3 * * * * /export/home/comp/perl/foo/automail2014/gotest

- When I do '/etc/init.d/crond start' it says cron is already running. When I do '/etc/init.d/crond restart' I don't get an error, and cron seems to restart.

- Output from an alias which does 'ls -lut /etc/init.d/cron; ls -lut /etc/crontab; ls -lut /etc/cron.hourly; ls -lut /etc/cron.daily; ls -lut /var/spool/cron' shows this. I restarted cron on Aug 20 8:09am, but something ran on Aug 21 at 4:02am.

Code:

# ls -lut /etc/init.d/crond
-rwxr-xr-x 1 root root 1926 Aug 20 08:09 /etc/init.d/crond*
# ls -lut /etc/crontab
-rw-r--r-- 1 root root 255 Aug 20 08:09 /etc/crontab
# ls -lut /etc/cron.hourly
total 0
# ls -lut /etc/cron.daily
total 56
lrwxrwxrwx 1 root root  39 Aug 21 06:14 0logwatch -> /usr/share/logwatch/scripts/logwatch.pl*
-rwxr-xr-x 1 root root  296 Aug 21 04:03 rpm*
-rwxr-xr-x 1 root root  100 Aug 21 04:03 tetex.cron*
-rwxr-xr-x 1 root root  354 Aug 21 04:03 tmpwatch*
-rwxr-xr-x 1 root root  256 Aug 21 04:03 rhsmd*
-rwxr-xr-x 1 root root  137 Aug 21 04:02 mlocate.cron*
-rwxr-xr-x 1 root root 2181 Aug 21 04:02 prelink*
-rwxr-xr-x 1 root root  418 Aug 21 04:02 makewhatis.cron*
-rwxr-xr-x 1 root root  118 Aug 21 04:02 cups*
-rwxr-xr-x 1 root root  180 Aug 21 04:02 logrotate*
-rwxr-xr-x 1 root root  379 Aug 21 04:02 0anacron*
# ls -lut /var/spool/cron/
total 4
-rw------- 1 chuck root 390 Aug 21 06:05 chuck

- doing 'ps -ae|grep cron' yields this:

Code:

29271 ?        00:00:00 crond
- /var/log/cron gets updated with something. Looks like my test script is running. Here's /var/log/cron, last few lines:

Code:

Aug 21 04:10:01 xpp crond[6756]: (chuck) CMD (/export/home/comp/perl/foo/automail2014/gocron)
Aug 21 05:01:01 xpp crond[6951]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 05:03:01 xpp crond[6960]: (chuck) CMD (/export/home/comp/perl/foo/automail2014/gotest)
Aug 21 05:10:01 xpp crond[6996]: (chuck) CMD (/export/home/comp/perl/foo/automail2014/gocron)
Aug 21 06:01:01 xpp crond[7298]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 06:03:01 xpp crond[7337]: (chuck) CMD (/export/home/comp/perl/gilson/automail2014/gotest)
Aug 21 06:05:22 xpp crontab[7370]: (chuck) BEGIN EDIT (chuck)
Aug 21 06:06:04 xpp crontab[7370]: (chuck) END EDIT (chuck)
Aug 21 06:10:01 xpp crond[7397]: (chuck) CMD (/export/home/comp/perl/foo/automail2014/gocron)
Aug 21 06:22:10 xpp crontab[7496]: (chuck) LIST (chuck)

- I've already taken a look at some pages I googled with no luck.

Any ideas what else I can check? Should we reboot the server? We just rebooted on Monday.

BhushanPathak 08-21-2014 05:28 AM

Have you checked whether the script 'gotest' has executable permission?

- Bhushan

bulrush15 08-21-2014 05:40 AM

Yes it has exe permission for all people. I just added that to my original post.

EDIT: Got it! When I put root in /etc/cron.allow, and restarted cron it worked.


All times are GMT -5. The time now is 08:01 AM.