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