- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- works on command line but does not work 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
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
тАО10-10-2006 12:25 AM
тАО10-10-2006 12:25 AM
I made one script which code I will post...script works fine from CL but in cron it has problems with second nawk. Script:
nawk -F"|" '
{ s=substr($104,2,18)}
{b[s] ++s}
END { for (i in b) print i, b[i] } ' $1 > /path/to/file/TranId_www$2
q=$(cat /path/to/file/TranId_www$2 | wc -l)
echo $q > /path/to/file/zawww
nawk -F"|" -v x=$2 -v w=$(/usr/bin/cat /path/to/file/zawww) '
{u=u+1; l=l+$66}
($66 != 0)&&($110 == 1)&&($111 == 0) { a=a+1; s=s+$66}
END { print x"|"u"|"l"|"w"|"s } ' $1 >> statistic_www
Also note that I got TranId_www$2 after script exec. in cron but statistic_www can not be appended..what might be an issue?
Pleaseeeee can anyone figure out what is problem and why does second nawk make problems??
THANKS in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 12:29 AM
тАО10-10-2006 12:29 AM
Re: works on command line but does not work in cron
Unless you have established your own PATH in your script, 'cron' has only provided a minimal one, notably:
PATH=/usr/bin:/usr/sbin:.
Make sure that you have what you think you do!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 12:34 AM
тАО10-10-2006 12:34 AM
Re: works on command line but does not work in cron
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 12:54 AM
тАО10-10-2006 12:54 AM
Re: works on command line but does not work in cron
cat and echo may be missing their paths.
do you have a correct:
/path/to/file/zawww
file ?
You could run the script in debug mode (include "set -x" as the start of the script)
to track the path of code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 12:55 AM
тАО10-10-2006 12:55 AM
Re: works on command line but does not work in cron
Cron runs with only a limited shell - be sure to fully the path to all commands.
In fact you may need to explicitly set some more environment variables that are not set by cron limited shell.
This is sometimes bypassed by using
su -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 01:11 AM
тАО10-10-2006 01:11 AM
Re: works on command line but does not work in cron
it is not problem with path becouse I have my other script similar almost like this one:
nawk -F"|" -v x=$2 '
{u=u+1; l=l+$66}
($66 != 0)&&($110 == 1)&&($111 == 0) { a=a+1; s=s+$66}
#$66 != 0 { a=a+1; s=s+$66}
END { print x"|"u"|"l"|"a"|"s } ' $1 >> statistic_www
and this works from my cron..so as U can see it can recognise nawk and other things..but in script from my first post first nawk is executed brcouse I can see TranId_www$2 but second is not becouse file does not append..
any better ideas?? thanks for reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 04:33 AM
тАО10-10-2006 04:33 AM
Re: works on command line but does not work in cron
#!/usr/bin/sh
export PATH=/usr/bin
However, in your code, you have not specified a location for the file "statistic_www". It will need a fullpath to ensure it goes where you want it. cron runs your script on your behalf but never performs a login so none of your /etc/profile and .profile will be run. And to further troubleshoot the problem, add the command set -x at the beginning of the script.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 07:15 AM
тАО10-10-2006 07:15 AM
Re: works on command line but does not work in cron
have you looked for statistic_www
in the cron user's home directory?
Does the mail to the cron user give any clue?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 04:02 PM
тАО10-10-2006 04:02 PM
Re: works on command line but does not work in cron
I guess you have not defined which shell you are using, try defining in the first line of the script.
regards
hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2006 05:59 PM
тАО10-10-2006 05:59 PM
Re: works on command line but does not work in cron
as U can see it is almost the same script no export PATH, no specificatio on shell, no path to statistic_www...and this script works just fine in cron! but script that I published in first post can not be completely executed in cron..
any clue??
thanks I hope that someone will give me a good hint which I have not tried yet.