- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Environemnt under cron execution
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
Forums
Discussions
Discussions
Discussions
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
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
06-28-2002 10:42 AM
06-28-2002 10:42 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2002 10:45 AM
06-28-2002 10:45 AM
SolutionYou could source the .profile for the user, but since .profile expects an interactive session you will get some errors like "stty: not a typewriter".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2002 10:47 AM
06-28-2002 10:47 AM
Re: Environemnt under cron execution
* * * * * . ./.profile > /dev/null; your_cron_script
HTH
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2002 10:48 AM
06-28-2002 10:48 AM
Re: Environemnt under cron execution
Your script can explicitly set PATH and export it or a better method is to do something like this:
Let's suppose that this is some kind of Oracle script so the ORACLE_HOME, ORACLE_SID .. needs to be set.
The best way is to create a file. e.g. /usr/local/bin/oraenv.sh that sets and exports these variables and the PATH; this file must not have a return or exit statement.
Now BOTH the .profile AND your cron script source source /usr/local/bin/oraenv.sh.
The reason you don't source .profile is that several statements (e.g. stty, tabs, ...) require a tty device for stdin & stdout.
You could wrap those commands in your .profile with
if [ -t 0 -a -t 1 ]
then
tset ..
stty ..
tabs ..
fi
but it's much cleaner to have a common file that is references by all the relevant .profiles and scripts.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2002 11:03 AM
06-28-2002 11:03 AM
Re: Environemnt under cron execution
Something I really like in Linux is /etc/system/functions. While some of it would not make sense in other Unices the basic functions for super-user needs are there.
i.e.
killproc()
statproc()
I took the idea back in Redhat 5.0 and ran with it. I now have some extensive external functions and paths (based on OS) which make scripting a breeze.
Best of Luck!
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 04:32 AM
07-01-2002 04:32 AM
Re: Environemnt under cron execution
This subject matter, i.e. environment variables and non-execution of .profile, is documented in the crontab(1) (i.e. "man crontab") manual page. It is documented in this page, and not in the cron(1M) page, because crontab(1) is a user command (i.e. the user which puts the entry in the crontab) and cron(1M) is a SysAdmin command.