Linux timed execution shell script _crontab

Source: Internet
Author: User

1. View tasks [[email protected] oraclebacka]$ crontab-l

2. New task [[email protected] oraclebacka]$ CRONTAB-E

3, 14 points per day 40 execute/backup/oraclebacka/sh.sh script, log output to/backup/oraclebacka/shlog.txt

* * * */backup/oraclebacka/sh.sh &>>/backup/oraclebacka/shlog.txt

Problem

1,/bin/sh:/backup/oraclebacka/sh.sh:permission denied

Shell script does not have execute permission, chmod 755 sh.sh

2,/backup/oraclebacka/sh.sh:line 59:ctxlc:command not found
/backup/oraclebacka/sh.sh:line 67:sqlplus:command not found
/backup/oraclebacka/sh.sh:line 69:ctxlc:command not found
/backup/oraclebacka/sh.sh:line: [:: Integer expression expected
/backup/oraclebacka/sh.sh:line 106:sqlplus:command not found
/backup/oraclebacka/sh.sh:line 108: [:: Integer expression expected
/backup/oraclebacka/sh.sh:line 136: [:: Integer expression expected
/backup/oraclebacka/sh.sh:line 136: [:: Integer expression expected

You may have noticed in the example above that each command gives an absolute path. When using C R o N T a b run s H e l l
Script, the user will be given the absolute path of the script, set the appropriate environment variables. Remember, since it is the user to C R o n
By submitting these jobs, you need to provide all the required environment to C R o N. Do not assume that C R o N knows the desired special environment, it
actually don't know. So you have to make sure to provide all the necessary path and environment variables in the S H e L script, in addition to some automatic
Sets the global variable.

There are two ways to export or copy to/etc/profile inside a shell.

The first of these solutions:

To view the environment variables for a user running C R o N T a b task:. bash_profile file Vi/home/oracle/.bash_profile

Copy the export path Oracle_base oracle_home oracle_sid to the shell script and place it at the beginning of the shell script

In the shell script:

Export Oracle_base=/u01/oracle Export oracle_home=/u01/oracle/app/12.1.0

The second solution:

Copy the settings from the. bash_profile file to the/etc/profile file, but use the root user

Linux timed execution shell script _crontab

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.