- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh script works fine but NOT in CRON
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
03-04-2002 09:13 AM
03-04-2002 09:13 AM
ksh script works fine but NOT in CRON
How come this k-shell script
I got works fine executed
directly:
#./freespace
But when I put it in cron:
* * * * 1-5 /var/adm/admin/freespace > /dev/null 2>&1
All I get is this output:
Name Tot[MB] Free[MB] Used[MB] Used[%]
with no data...
I'm using an HP-UX 11.0.
I have attached a copy of the
script with the output from
executing directly.
Thanks,
Laurie K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 09:16 AM
03-04-2002 09:16 AM
Re: ksh script works fine but NOT in CRON
Add the line
env > /tmp/env
to the script and compare.
I'd also suggest adding /usr/bin/ to every command.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 09:18 AM
03-04-2002 09:18 AM
Re: ksh script works fine but NOT in CRON
It's not because it's ksh but rather that the environment under cron is intentionally very sparse. You must modify the script so that either everything is called with an absolute path or something like:
PATH=${PATH}:/usr/bin:/sbin:/usr/local/bin
export PATH
This same rule applies to any environment variables that your script is using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 09:19 AM
03-04-2002 09:19 AM
Re: ksh script works fine but NOT in CRON
When using cron, you should ALWAY's use fully qualified path names. And never assume any environmental variable will be available.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 09:20 AM
03-04-2002 09:20 AM
Re: ksh script works fine but NOT in CRON
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 10:11 AM
03-04-2002 10:11 AM
Re: ksh script works fine but NOT in CRON
Seems like the script is unable to execute because it is unable to find the commands you are using to get the output. Suggest sun it as a user,
* * * * 1-5 su - user_name -c "/var/adm/admin/freespace > /dev/null 2>&1"
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2002 11:38 AM
03-05-2002 11:38 AM
Re: ksh script works fine but NOT in CRON
Anyway, as Clay and Sanjay were saying, the default environment is sparse. Your script will either need to be run from an su call to an account with the appropriate environment, or it will need to source/set PATH, INFORMIXDIR, and ONCONFIG, etc itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2002 05:13 AM
03-07-2002 05:13 AM
Re: ksh script works fine but NOT in CRON
If a script is not supposed to generate output to standard output and standard error, then it is a bad idea to supress such output.
I.e. if you had left off the "> /dev/null 2>&1" from the crontab entry, you would probably have gotten mail with an error message, which would have pointed you to the cause.
So *only* use "> /dev/null 2>&1" if you know the script *will* generate output to standard output and standard error, and you do *not* want that output.