Jay
Jay

Reputation: 1422

cron job fails to restart services

I have a simple script that stops and starts the services (of Oracle Hyperion)

#!bin/ksh

/path/to/dir/stop.sh

sleep 1200

/path/to/dir/start.sh

I have scheduled it for every night and it does run, however there is an issue with database connectivity afterwards. But when i run stop.sh and start.sh manually, there is no such issue. Obviously the job had not run completely.

Here's the output from crontab -l

00 02 * * * /export/home/oracle/scheduled_restart.sh

Could someone please advise on the problem? Thanks.

Upvotes: 0

Views: 1596

Answers (1)

jim mcnamara
jim mcnamara

Reputation: 16379

The usual cause for cron jobs to differ from command line during execution of the exact same code is environment, specifically the variables like ORACLE_SID, TWO_TASK, LD_LIBRARY_PATH, and so on.

Assuming the oracle user own the crontab: When a job is run by crond it does the equivalent of su oracle, not su - oracle. Try doing something to ensure that the command sources everything the oracle user would normally source during login.

To see what is going on:

/export/home/oracle/scheduled_restart.sh && set > /tmp/my_variables.txt

You do not need the /bin/sh if the /export/home/oracle/scheduled_restart.sh file is executable. It should have a shebang on line 1. ex: #!/bin/ksh for korn shell or whatever shell you use.

Upvotes: 1

Related Questions