Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: scheduling query with crontab

    Can you please help. I want to run a query at midnight everyday. The query is a simple one and it goes like 'SELECT * FROM table_name' and save the output to a file in unix directory. Currently iam able to save the output to a file from a command line with this statement

    #isql -SGBOMC1 -Ppasswd -Uusername -ofile
    select * from table_name
    go

    Now I want to put this in a crontab so that it runs every midnight and I am having difficulty doing that and will appriciate any help.

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    Create a Shell script including all the necessary environment variables & path. The cronjob is executed outside your environment.

    File myTSQL.ksh
    Code:
    #!/bin/ksh
    . ~/.profile 
    $SYBASE/$SYBASE_OCS/bin/isql -Usa -Pxxx -DDbName -SASE125 <<EOF
    select * from...
    go
    EOF
    Don't forget to provide correct permissions
    Code:
    chmod 700 myTSQL.ksh
    Add the following line in a crontab -e
    Code:
    01 00 * * * /users/sybase/myScript/myTSQL.ksh > /tmp/tmpSQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •