1752790 Members
6230 Online
108789 Solutions
New Discussion юеВ

Re: crontab

 
Tonatiuh
Super Advisor

crontab

Red Hat Enterprise Linux AS 3U6

I have a crontab for oracle user and everithing seems to be well but it does not execute.

I can execute manually the script, but it is never execute by the crontab.

Any ideas abot what to check?
13 REPLIES 13
Steven E. Protter
Exalted Contributor

Re: crontab

Shalom,

cron has a limited environment. The most common problem is the PATH variable is not the same.

From command line:

env > /tmp/env.txt

Some environment variable in that file is missing when cron runs.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Tonatiuh
Super Advisor

Re: crontab

This is mis script:

export ORACLE_SID=lcprod01n1
export ORACLE_HOME=/opt/oracle/rdbms/9.2.0
echo "Inicia "$ORACLE_SID": "$(date +"%Y-%m-%d %H:%M.%S") >> /home/oracle/runstat.log
$ORACLE_HOME/bin/sqlplus /nolog @/home/oracle/scripts/runstat.sql
echo "Termina "$ORACLE_SID": "$(date +"%Y-%m-%d %H:%M.%S") >> /home/oracle/runstat.log

If the problem would be the envirnoment, at least the line where I log the "inicia (start)" should be executed, but does not.
Steven E. Protter
Exalted Contributor

Re: crontab

Shalom,

90% of the time its the PATH variable.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: crontab

Can you post the crontab entry? Let's see what may be wrong.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Tonatiuh
Super Advisor

Re: crontab

$ crontab -l
58 20 * * * /home/oracle/scripts/runstat.sh

Ivan Ferreira
Honored Contributor

Re: crontab

Please change to:

$ crontab -l
58 20 * * * /home/oracle/scripts/runstat.sh > /tmp/runstat.log 2>&1


Set the time execute right now and then post the /tmp/runstat.log file.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Tonatiuh
Super Advisor

Re: crontab

Ivan,

The /tmp/runstat.log was not generated. The script was never executed.
Ivan Ferreira
Honored Contributor

Re: crontab

Wow, please post the output of:

service crond status

tail /var/log/cron

Or check in /var/log/cron what happened with your job.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Tonatiuh
Super Advisor

Re: crontab

[root@ita1 mail]# service crond status
crond (pid 12343) is running...
[root@ita1 mail]# tail /var/log/cron
Sep 27 21:40:06 ita1 crontab[12805]: (oracle) REPLACE (oracle)
Sep 27 21:40:06 ita1 crontab[12805]: (oracle) END EDIT (oracle)
Sep 27 21:41:01 ita1 crond[12343]: (oracle) RELOAD (cron/oracle)
Sep 27 22:01:01 ita1 crond[13006]: (root) CMD (run-parts /etc/cron.hourly)
Sep 27 22:25:44 ita1 crontab[13222]: (oracle) BEGIN EDIT (oracle)
Sep 27 22:26:02 ita1 crontab[13222]: (oracle) END EDIT (oracle)
Sep 27 22:26:09 ita1 crontab[13225]: (oracle) BEGIN EDIT (oracle)
Sep 27 22:26:29 ita1 crontab[13225]: (oracle) REPLACE (oracle)
Sep 27 22:26:29 ita1 crontab[13225]: (oracle) END EDIT (oracle)
Sep 27 22:27:01 ita1 crond[12343]: (oracle) RELOAD (cron/oracle)