0

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.

Jay
  • 1,392
  • 7
  • 17
  • 44

1 Answers1

1

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.

jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
  • I'm not sure if the oracle user 'owns' crontab, but the user is in the cron.allow list, along with root. I'll try it when i get the chance and let you know how it goes – Jay Feb 19 '13 at 03:42
  • "owns" means the user can create and edit a crontab. cron.allow does that. Since you executed crontab -l okay, then you are good to go. – jim mcnamara Feb 19 '13 at 03:47
  • We added the lines to set the environment variables in the script, and then it was alright. – Jay Feb 20 '13 at 02:16