SQL plus error during crontab timing

Source: Internet
Author: User


Crontab timing sqlplus Error Problem today I plan to use linux to regularly select the data that I need to query every day at work. But I do not know anything about linux scheduled tasks. so, from scratch: Linux uses the crontab command to execute scheduled tasks. 1. view the current scheduled tasks crontab-l2 and write new scheduled tasks. The operation mode of editing a task is the same as that of vi. Crontab-e, 3, save the scheduled result www.2cto.com Example 1: Execute the ls command at every day, output the result to the/jp/test file for 30 5 * ls>/jp/test 2> & 1 Note: 2> & 1 indicates the execution result and error message. The scheduled task format is divided into six sections. The first five sections are the time setting sections, and the sixth section is the command section to be executed. The format is as follows: mi hh dd mm dw command explanation: the number of minutes that mi executes this task every hour. The value range is 0 ~ 59 hh: The hour in which the task is executed every day. The value range is 0 ~ 23 dd: execute this task on the day of every month. The value range is 1 ~ 31mm executes the task in the month of each year. The value range is 1 ~ 12 dw executes the task the day of every week. The value range is 0 ~ 6. 0 indicates that the program www.2cto.com to be executed is specified by the command on Sunday. The example is as follows: * ls indicates that the ls command is executed once every 5th minutes of every hour. * 5 * ls indicates that the ls command is executed at every day. * 7 8 * ls indicates the 8 th day of every month. execute the ls command at AM 30 5 8 6 * ls to specify to execute the ls command at AM on April 9, June 8*0 ls to specify to execute the ls command at AM on every Sunday. [Note: 0 indicates Sunday, 1 indicates Monday, and so on. sun indicates Sunday, mon indicates Monday, and so on.]
30, 20 ** ls: Execute the ls command at on the 10th and 20th of every month [Note: ", [Note: "-" is used to connect to consecutive periods] */15 ***** ls executes the ls command every 15 minutes [that is, the ls command is executed every hour for 0th 15 30 45 60 minutes] 30 6 */10 ** ls every month, run the ls command at every 10 days [that is, run the ls command at on the 1st, 11th, 21st, and 31st of every month.] After a simple understanding of crontab usage, start to create the first scheduled task. The script is as follows: cd/home/oracle .. bash_profilesqlplus userid/password @ TNS_NAME <! Select * from tab; exit; www.2cto.com! Error: 1 ,. bash_profile: file not found2, sqlplus: command not found first error solution: Use source/home/oracle /. bash_profile. Since you cannot find it, I will give you an absolute path. The solution for the second error is similar to that for the first error. The absolute path is also used, but you still cannot figure it out. Now that the source environment variable has been successfully created, the system should be able to successfully find the sqlplus path. The modified script is #! /Bin/bash www.2cto.com cd/home/oraclesource/home/oracle /. bash_profile/home/oracle/product/11.2.0/client/bin/sqlplus userid/password @ TNS_NAME <! Select * from tab; exit ;! Conclusion: It is best to add the absolute path of the command to the script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.