- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sourcing /etc/profile and .profile in cronjobs
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
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
10-06-2003 05:18 AM
10-06-2003 05:18 AM
In HP-UX 11i, is there any simple and standard way to source .profile and /etc/profile in a cronjob than just explicitly add lines
" . $HOME/.profile
. /etc/profile" in the cronjob scripts?
We are running HP-UX 11.00 ( we will be moving to 11i soon) and we do explicitly call /etc/profile & .profile in cron job scripts. But I think this is not a nice method. Any better ways?
Thanks & regards,
Jegi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 05:22 AM
10-06-2003 05:22 AM
Re: sourcing /etc/profile and .profile in cronjobs
"Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry."
I'll follow the thread for a while to see if anyone has a way, because I do the same thing when needed.
--Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 05:24 AM
10-06-2003 05:24 AM
Re: sourcing /etc/profile and .profile in cronjobs
That's the only way I know of.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 05:32 AM
10-06-2003 05:32 AM
SolutionAlthough outright sourcing *will* work the majority of the time, you have to be careful about routines in the profiles that are looking for a terminal. In these cases where there is NO terminal, you'll get the messages like:
process not attached to terminal
Usage: who [-rbtpludAasHTqRm] [am i] [utmp_like_file]
r run level
b boot time
t time changes
p processes other than getty or users
l login processes
u useful information
d dead processes
A accounting information
a all (rbtpludA options)
s short form of who (no time since last output or pid)
H print header
T status of tty (+ writable, - not writable, x exclusive open, ? hung)
q quick who
R print host name
ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
Now normally this isn't a big problem, but it can be avoided by creating a file to source all the necessary environment variables from without ANY code or routines that might be looking for a terminal.
Then you can just source that file in the profile & .profile files as well as the beginning of any cron job scripts.
My $0.02,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 06:31 AM
10-06-2003 06:31 AM
Re: sourcing /etc/profile and .profile in cronjobs
if [[ -t 0 ]]
then
tput
tset
...
fi
but the far better way is to create a file which sets and exports any needed variables, e.g. /usr/local/bin/myenv.sh and then both your .profile and cron scripts source this file via the dot command. This sources file must not contain an exit or return statement or it will have the unintended effect of exiting the foreground (shell) process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2003 06:43 AM
10-06-2003 06:43 AM
Re: sourcing /etc/profile and .profile in cronjobs
The only way I know of to ensure that all required environment variables are set in cron jobs is to either code them in the script, or source a file containing the required variables. This *could* be /etc/profile or .profile, but you would be better off to create a separate script containing just the variables required.
Pete
Pete