- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- jobs via cron and their path
Operating System - HP-UX
1819927
Members
3255
Online
109607
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО09-10-2002 04:16 PM
тАО09-10-2002 04:16 PM
Hi....
system D390
Op sys - ux11.00
I have a job when I run using the at cmd is successful - appears to travel the correct paths and picks up the correct values for env variables. But, (there always appears to be one of these!) when I leave the job to run under instruction from cron it fails because it is not picking up the correct environement variable. Does anyone have any suggestions as to how I can work out where the job is picking up the wrong env variable. ?
Appreciate your help with this one.
Thanks, Maria.
system D390
Op sys - ux11.00
I have a job when I run using the at cmd is successful - appears to travel the correct paths and picks up the correct values for env variables. But, (there always appears to be one of these!) when I leave the job to run under instruction from cron it fails because it is not picking up the correct environement variable. Does anyone have any suggestions as to how I can work out where the job is picking up the wrong env variable. ?
Appreciate your help with this one.
Thanks, Maria.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2002 04:24 PM
тАО09-10-2002 04:24 PM
Re: jobs via cron and their path
Easiest way is to make SURE that you declare ANY and ALL environment variables that your script needs within the script.
It's probably picking something up from your .profile that doesn't necessarily get seen via cron.
It's probably picking something up from your .profile that doesn't necessarily get seen via cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2002 04:38 PM
тАО09-10-2002 04:38 PM
Solution
Cron has an intentionally sparse environment. Don't be tempted to do an su - username command inside a script called by cron because it will almost certainly fail. You have two options: 1) set an export all the enviroment variables including PATH inside your cron script or 2) - better - allow your cron script to source a file e.g. . /usr/local/bin/myenv.sh that sets and exports any needed variables. There should be no return or exit statements in this sourced file. You could also choose to source this same file from any desired user's .profile so that you only have to make any changes to the environment in one place.
You are experiencing perfectly normal behavior for cron. The other common error is invoking commands which expect to be connected to sort sort of serial device like a terminal and you don't have one under cron.
You are experiencing perfectly normal behavior for cron. The other common error is invoking commands which expect to be connected to sort sort of serial device like a terminal and you don't have one under cron.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2002 05:42 PM
тАО09-10-2002 05:42 PM
Re: jobs via cron and their path
Hi,
Sometimes in your convenient, you always set your environment variable in .profile or some other file that will executed by .profile. So when you logon to the system, you will always get all the setting you want.
But when you executed the job in cron, it just 'run' the job ONLY and will note set any environment that you need. So, there is 2 ways to do so,
1. Always execute the .profile or set the appropriate variables in your script.
OR
2. When submit the job in cron, you must type
* * * * * (. /home//.profile; /yourpath/yourjob)
Regards,
Patrick
Sometimes in your convenient, you always set your environment variable in .profile or some other file that will executed by .profile. So when you logon to the system, you will always get all the setting you want.
But when you executed the job in cron, it just 'run' the job ONLY and will note set any environment that you need. So, there is 2 ways to do so,
1. Always execute the .profile or set the appropriate variables in your script.
OR
2. When submit the job in cron, you must type
* * * * * (. /home/
Regards,
Patrick
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP