- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script runs fine from command line not as cron job...
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
11-30-2007 01:14 AM
11-30-2007 01:14 AM
The purpose is for future planning reasons, I think we are butting heads with a license limit.. When I run it manually I get the output desired:
# dbgo.sh
Arlington User Count
0
Blair User Count
0
Conestoga User Count
0
DCWest User Count
0
ESU User Count
8
ELKHORN User Count
6
FT Calhoun User Count
0
Gretna User Count
1
Millard User Count
21
Papillion LV:User Count
10
Ralston User Count
1
Westside User Count
7
When ran in cron the output shows "0"
Here are the scripts.. I am hoping someone with better eyes might be able to tell me what I am doing wrong.
SCRIPT#1
# cat dbusr
for duser in `/usr/informix/bin/onstat -g ses|/usr/bin/grep -v informix |/usr/bin/awk '{print $2}'`
do
grep $duser /etc/passwd
done
SCRIPT#2 (want to run in cron to build log)
# cat dbgo.sh
/usr/local/bin/dbusr > /tmp/dbusr.out
echo "Arl User Count" > /tmp/dbusr.log
grep '\/arl\/' /tmp/dbusr.out |wc -l >> /tmp/dbusr.log
echo "Blr User Count" >> /tmp/dbusr.log grep '\/blr\/' /tmp/dbusr.out |wc -l >> /tmp/dbusr.log
.......
echo "WST User Count" >> /tmp/dbusr.log grep '\/wst\/' /tmp/dbusr.out |wc -l >> /tmp/dbusr.log
Any insight appreciated
Rex M - ESU#3
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 01:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 01:23 AM
11-30-2007 01:23 AM
Re: Script runs fine from command line not as cron job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 02:54 AM
11-30-2007 02:54 AM
Re: Script runs fine from command line not as cron job.
put in the
#!/usr/bin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 02:57 AM
11-30-2007 02:57 AM
Re: Script runs fine from command line not as cron job.
To see precisely what your environment is, put an 'env' in your script and let it run via cron. Then compare that with the output of 'env' from the command prompt. You will then need to set any needed variables explicitly in your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 03:00 AM
11-30-2007 03:00 AM
Re: Script runs fine from command line not as cron job.
Remember, that when a crontask runs, its environment is sparse. This is documented in the 'crontab(1)' manpages.
If you are relying on environmental variables that are build during a login shell (i.e. as defined in a '.profile') then unless you source (read) that profile (or antoher file that defines them), your cron'ed environment lacks them.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 03:09 AM
11-30-2007 03:09 AM
Re: Script runs fine from command line not as cron job.
Thanks. I need to go home and take some nyquil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2007 03:46 AM
11-30-2007 03:46 AM