ba6.us - Dave's Database Related Stuff

  • home
  • blog
  • notebooks
  • projects
  • recent
  • about
  • manifesto
  • !
Home › Unix Shell Scripting

Tag Cloud

apex Application Express Auditing data dbi development export funnies HTML Java linux monitoring oem oracle performance perl rman scripting sql SQL Developer sqlplus tuning unix windows
more tags

Search

RSS Feed

Blog Posts :

Navigation

  • Feed aggregator

User login

  • Request new password

Scheduling a Cron Job

dmann — Sat, 10/11/2008 - 20:39

Note that if you are wanting to schedule a script to run with Cron and execute SQLPLUS, you may have to make the script aware of the user environment variables like this:
#!/bin/sh
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
sqlplus -S perfstat/perfstat @query.sql > outfile.txt
To run a script with Cron automatically: 1) Log in to the OS as the user you want to execute the job. 2) Run "crontab -e" to edit the crontab configuration file 3) Add a line to the configuration file to specify the info about the job. The crontab file is organized like this:
*   *   *   *   *  /path/for/CommandToBeExecuted
-   -   -   -   -
|   |   |   |   |
|   |   |   |   +----- day of week (0=Sunday, 1=Monday, ... ,6=Saturday)
|   |   |   +------- month (1=Jan, ..., 12=December)
|   |   +--------- day of month (1 - 31)
|   +----------- hour (0 - 23)
+------------- min (0 - 59)
Example 1: Run example1.sh every day at 10:30am and 10:30pm:
30 10,22 0 0 0 /home/example1.sh
Example 2: Run example2.sh Monday-Friday at 7:00pm:
* 19 * * 1-5 /home/example1.sh
‹ Running SQLPLUS - A simple example... up
  • Printer-friendly version


Cornify
  • home
  • blog
  • notebooks
  • projects
  • recent
  • about
  • manifesto
  • !

Content Copyright 2006-2010. Links are copyright of respective owners.