Cron jobs not running

Hi All,

I am new to the Linux world.
Installed SLES 11 in virtual environment and wanted to configure cron jobs.
The cron status is as follows,


ls -lut /etc/init.d/cron

-rwxr–r-- 1 root root 4032 Jan 31 13:51 /etc/init.d/cron

ps -el | grep cron

1 S 0 4268 1 0 80 0 - 3697 ? ? 00:00:00 cron

ls -lut /etc/crontab

-rw-r–r-- 1 root root 255 Jan 31 13:52 /etc/crontab

ls -lut /etc/cron.daily

-rwxr-xr-x 1 root root 587 Jan 31 10:45 logrotate
-rwxr–r-- 1 root root 948 Jan 31 10:45 suse-clean_catman
-rwxr-xr-x 1 root root 1875 Jan 31 10:45 suse.de-backup-rc.config
-rwxr-xr-x 1 root root 2059 Jan 31 10:45 suse.de-backup-rpmdb
-rwxr-xr-x 1 root root 566 Jan 31 10:45 suse.de-check-battery
-rwxr-xr-x 1 root root 1314 Jan 31 10:45 suse.de-clean-tmp
-rwxr-xr-x 1 root root 371 Jan 31 10:45 suse.de-cron-local
-rwxr–r-- 1 root root 1693 Jan 31 10:45 suse-do_mandb

#crontab -l

DO NOT EDIT THIS FILE - edit the master and reinstall.

(/tmp/crontab.XXXXzw1pk8 installed on Thu Jan 31 14:51:56 2013)

(Cron version V5.0 – $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)

53 14 * * * ll > /tmp/cron_test.txt

Is not getting executed as scheduled…

Requesting your help !!!

Warm Regards,

Jitendra

‘ll’ is an alias; try something a little less magical to debug:

Code:

          • /usr/bin/echo /usr/bin/date >> /tmp/testcron./usr/bin/date +%s

Good luck.

It didn’t work either.
The commands execute from the terminal sessions but not as a cron job

Pl. help

What does the logs - messages localmessages - tell you for the time your cron job should run?

Hi jmhalgi,

ps -el | grep cron

an easier way to determine if cron is actually running, is via “rccron status”, executed as root

Any output generated by cron jobs is usually sent via email to the owning user of the cron tab, in your case that should be the root user. Anything to find there, in addition to any messages in syslog (grep CRON /var/log/messages) as asked by Hans?

A simple test entry could be

The time stamp of /tmp/cron.lastrun should follow the current time, verified by “ls -l /tmp/cron.lastrun”.

Do the status files of cron.daily etc suggest that cron is actually doing something, by displaying an appropriate (current) time stamp?

[QUOTE]# ls -l /var/spool/cron/lastrun/
total 0
-rw-r–r-- 1 root root 0 Feb 13 13:15 cron.daily
-rw-r–r-- 1 root root 0 Feb 7 16:00 cron.weekly[/QUOTE]

Regards,
Jens

Hi Jens,

Sorry for the delayed response.

Following are the details,

rccron status

Checking for Cron: running

crontab -l

DO NOT EDIT THIS FILE - edit the master and reinstall.

(/tmp/crontab.XXXXeYKqQv installed on Mon Mar 4 11:10:59 2013)

(Cron version V5.0 – $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)

          • /usr/bin/touch /tmp/cron.lastrun

– Checked after 5 min

ls -l /tmp/cron.lastrun

ls: cannot access /tmp/cron.lastrun: No such file or directory

ls -l /var/spool/cron/lastrun/

total 0
-rw-r–r-- 1 root root 0 Mar 4 10:45 cron.daily

— Some additional info
Configured ‘cron’ job for another user. The crontab entry is as below,

45 8 * * * /bin/df >> /oracle/SID/jm.txt 2>&1

45 9 * * * /bin/df >> /oracle/SID/sch_jobs/dt.txt 2>&1

The first job runs well, everyday at 8.45am. But the second job doesn’t run.
The permissions on /oracle/SID/sch_jobs are 777 so that is not an issue.

Can you pl. guide further ?

Warm Regards,

Jitendra

45 8 * * * /bin/df >> /oracle/SID/jm.txt 2>&1[color=blue]

45 9 * * * /bin/df >> /oracle/SID/sch_jobs/dt.txt 2>&1

The first job runs well, everyday at 8.45am. But the second job doesn’t
run.
The permissions on /oracle/SID/sch_jobs are 777 so that is not an
issue.[/color]

Is it safe to assume that you waited another hour for the second job to
run, and that after that hour had elapsed the system was still on and in
the same state as it was when the first job ran? Why not have them set to
the same time for a better test?

Good luck.

Hi Jitendra,

[QUOTE=jmhalgi;12207]Hi Jens,
[…]

rccron status

Checking for Cron: running

crontab -l

DO NOT EDIT THIS FILE - edit the master and reinstall.

(/tmp/crontab.XXXXeYKqQv installed on Mon Mar 4 11:10:59 2013)

(Cron version V5.0 – $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)

          • /usr/bin/touch /tmp/cron.lastrun

– Checked after 5 min

ls -l /tmp/cron.lastrun

ls: cannot access /tmp/cron.lastrun: No such file or directory[/QUOTE]

What does “grep cron /var/log/messages” report (if your host’s syslog is redirected somewhere else, search that destination, of course :wink: )? For each invocation you should usually see an according message similar to

Mar  4 11:00:01 yourhost /usr/sbin/cron[10363]: (root) CMD (/usr/bin/touch /tmp/cron.lastrun)

and the invocations of “crontab -l” should leave their traces there, too.

If you “see” your cron jobs once per minute, does your root user receive any error mails concerning the invocations - as “ls” doesn’t show any result (while cron seems to run, according to i.e. syslog and /var/spool/cron/lastrun/), some error then must have occurred…

Regards,
Jens