- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: crontab and user environment
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 06:54 AM
тАО08-02-2001 06:54 AM
I was doing some shells and I am able to execute them fine from the command line and it works great.
Once I added the line that executes de shell in the users's cron it doesn't work correctly.
I'm not sure if it is the environment wich doesn't load correctly from the cron...
It would be great if anyone could give me a push, also youcan ask for further info about the shell I know it's hard to understand the problem without seeing the code.
I would tell you that it doesn't even execute sqlplus wich is embedded in the shell.
Here's the mail that cron daemons sends when it tries to execute the shell...
Thanx in advance.
Bases_de_datos[13]: sqlplus: not found
/users/infra/SOPORTE/ED/monitor/log_creator.sh[18]: ./outbox/alertas.eml: cannot create
/users/infra/SOPORTE/ED/monitor/log_creator.sh[18]: ./outbox/alertas.eml: cannot create
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
/users/infra/SOPORTE/ED/monitor/gmon /users/infra/SOPORTE/ED/monitor
Thanx again.
Ed
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 06:58 AM
тАО08-02-2001 06:58 AM
Re: crontab and user environment
There is another post on similiar issue, maybe it is useful for you.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x67a972234586d5118ff00090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:00 AM
тАО08-02-2001 07:00 AM
Re: crontab and user environment
Either set PATH to where your executables are or specify the full path on commands and files. ie /opt/oracle/bin/sqlplus
-- Rod H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:01 AM
тАО08-02-2001 07:01 AM
Re: crontab and user environment
you have to set everything that yout shell has in your cron scrip, otherwise your script won't run.
You could do something like the following:
1. collect your environement in a file
env > /tmp/en
2. insert this file at the beginning of you cron script
3. try it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:03 AM
тАО08-02-2001 07:03 AM
SolutionThis is a very common occurence. The environment under which a cron job is run is intentionally very sparse.
You script need's to set ORACLE_HOME, ORACLE_SID, ORACLE_BASE, TNS_ADMIN, PATH, ...
My favorite way to do this is to create a script in /usr/local/bin (e.g.) oraenv.sh
something like this:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=${ORACLE_BASE}/product/8.1.7
(Make sure you do not put an exit statement in the file)
and anything else
your cron script should then source this file
. /usr/local/bin/oraenv.sh
you should then set PATH
and start up script code
any database user should also source this file as part of their .profiles
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:04 AM
тАО08-02-2001 07:04 AM
Re: crontab and user environment
'cron's environment lacks all of your environmental variables (including your PATH) that you normally rely on (and forget about) when you are working in your normal login shell.
There are several ways to circument this and obtain a similar environment.
You can source your profile ahead of calling your script. This can be done in the crontab entry. Alternatively, you can source your profile within the script itself to provide the necessary environmental variables you need. Thirdly, you can create a new file which contains and exports the common variables needed for your application, and source (read) that within your standard profile, within standard scripts; and/or in a crontab stream.
To source (read) a file within a script, put a dot (".") in front of the script name. For instance, to source a file called /myscript you would do:
. /myscript #...note the space between the dot and the script name.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:06 AM
тАО08-02-2001 07:06 AM
Re: crontab and user environment
When executing using cron all the environment setting have to be set explicitly in the script. As cron does not login to run the script the environment with not be set.
Simply put, all the settings in the your .profile need to be in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2001 07:18 AM
тАО08-02-2001 07:18 AM
Re: crontab and user environment
You must execute, as first instruction in the crontab script, .profile file in order to have the environment variables set.
without doing that, only four environment variables are set.
Magdi