1753908 Members
8913 Online
108810 Solutions
New Discussion юеВ

Re: cron job not running

 
Deepu Chakravarty
Regular Advisor

cron job not running

I have one cron job defined in crontab as following. Which is intended to run every 15 mins. But it is not running. What may the reason:
0,15,30,45 * * * * /var/spool/cron/form_session_1

Other cron jobs defined in crontab are running perfectly. Is there any mistake in the format of the cron job?
10 REPLIES 10
Md. Farhan A Azam
Trusted Contributor

Re: cron job not running

Hi, Check excute permission is there or not

0,15,30,45 * * * * /sbin/sh /var/spool/cron/form_session_1

if its not working then post the output of,

#echo $SHELL
and the full error.
Deepu Chakravarty
Regular Advisor

Re: cron job not running

Full rights are there as following:

-rwxrwxrwx 1 root sys 405 Jan 15 10:42 form_session_1
Md. Farhan A Azam
Trusted Contributor

Re: cron job not running

hello,

can u post he

#echo $SHELL

and the full error, which u are getting
Deepu Chakravarty
Regular Advisor

Re: cron job not running

rp8420-oltpapp:/var/spool/cron>echo $SHELL
/sbin/sh

I am not getting any error. It is not running at all. I don't see any reference in /var/mail/root file of its running.
Md. Farhan A Azam
Trusted Contributor

Re: cron job not running

Hi, Try to run this script manually, is it working.
likid0
Honored Contributor

Re: cron job not running

First try to execute the script manually, if it works ok, then check:

the /var/adm/cron/log file and look for your script, if you see its executing ok, then check
your variables.

you have to remember that cron executes the scripts with:

warning: commands will be executed using /usr/bin/sh

check the scripts has all the variables it needs includind the PATH and others..
Windows?, no thanks
Matti_Kurkela
Honored Contributor

Re: cron job not running

Have you used "crontab -e" to configure the cron job? Or did you edit /var/spool/cron/crontabs/root directly?

You should always use the "crontab -e" command to edit crontabs. After the editing is complete, the "crontab -e" command will signal the cron process to indicate that the cron job files have been edited. If you edit /var/spool/cron/crontabs/root directly, this does not happen and cron will ignore your changes until you restart the cron daemon (/sbin/init.d/cron stop; /sbin/init.d/cron start) or reboot the system.

(If you don't like the "vi" editor, set the EDITOR environment variable to indicate your favorite editor. Then the "crontab" command will use your favorite editor too.)

Also check the logfile of the cron daemon: /var/adm/cron/log.

MK
MK
sujit kumar singh
Honored Contributor

Re: cron job not running

hi


as u have said that the other cron jobs are running , that means that the cron subsystem is working OK on the server.

Also that the syntax entry that u have made in the crontab file is OK as far as the syntax goes.

i assume that u are running this script as root.

check that this script runs perfectly as u try to run the saem from the command line.

if yes try to add to the command as u put the same in the crontab (use crontab -e to edit the cron file) to redirect the O/P to some file say /tmp/sript.out

as
0,15,30,45 * * * * /var/spool/cron/form_session_1 >> /tmp/sript.out

try running this as a cron and see the O/P of the file /tmp/sript.out

try comparing this O/P with that when u run this job directlyy from the command line.

u shall be able to differentiate.

Also the log of the tasks that are executed using cron is present in

/var/adm/cron/log

if u are using /var/adm/cron.allow and /var/adm/cron.deny then make sure that the user with whom the cron job shall be running is listed in the /var/adm/cron/cron.aloow file.




make sure that the first line in the script has

#!/usr/bin/ksh


Regards
Sujit

Avinash20
Honored Contributor

Re: cron job not running

Hi Deepu !!

The better way to troubleshoot this is to edit /var/spool/cron/form_session_1 and at the start of the script add "set -x"

set -x

After this in the crontab redirect the output to a file for which Sujit has posted the syntax

After this keep checking

# tail -f /var/adm/cron/log
Check if it fails with rc=*

Also check the file which you have redirect the output to..

This really provide a vital information

May be cron is running the script, but the script might be failing due to variable or permission issue if the script is writing to some file
"Light travels faster than sound. That's why some people appear bright until you hear them speak."