- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: top not running from cron entry..............
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
09-05-2007 09:29 PM
09-05-2007 09:29 PM
I m not able to run this script from cron,but when i run it from prompt , runs fine...........
# dattop.sh
DT=`/usr/bin/date|awk '{print $1}'`
TIME=`/usr/bin/date|awk '{print $2,$3,$4}'`
case $DT in
Mon )echo $TIME" ------>" `/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Monday.txt ;;
Tue )echo $TIME" ------>"`/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Tuesday.txt
;;
Wed )echo $TIME" ------>" `/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Wednesday.txt
;;
Thu )echo $TIME" ------>"`/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Thursday.txt
;;
Fri )echo $TIME" ------>"`/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Friday.txt
;;
Sat )echo $TIME" ------>"`/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Saturday.txt
;;
Sun )echo $TIME" ------>" `/usr/bin/top -n3 -d1|awk '{printf $61}'` >> /tmp/Sunday.txt
;;
esac
cron entry is as follows:->
5,10,15,20,25,30,35,40,45,50,55 * * * * /tmp/dattop.sh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2007 09:44 PM
09-05-2007 09:44 PM
Re: top not running from cron entry..............
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2007 09:47 PM
09-05-2007 09:47 PM
Re: top not running from cron entry..............
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2007 09:59 PM
09-05-2007 09:59 PM
Re: top not running from cron entry..............
Since cron has limited or no information on TERM/terminal information, your command will fail without the -f parameter directing the output to go to a file.
It is possible to set up environment in the script /tmp/dattop.sh
Also note that many sysadmins set up cron jobs that delete files that are older than a certain number of days in the /tmp filesystem to prevent congestion(full fs). This is probably not a great place to leave a production script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2007 11:25 PM
09-05-2007 11:25 PM
Re: top not running from cron entry..............
then how do i set my environment for this kind of script...
Plzz let me know...
Also denis why i cant use pipe and awk as the script runs fine in runtime.???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2007 08:36 AM
09-06-2007 08:36 AM
SolutionYou might be able to export TERM in your script and get it to work the same.
But you should not be trying to parse the top screen output. It is better to use the "-f file" output.
top -f doesn't support output to a unnamed pipe, and the "-" convention doesn't work.
So you would send the output to a file, use awk on it (this part will change since you have multiple lines), then remove the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2007 09:01 AM
09-06-2007 09:01 AM
Re: top not running from cron entry..............
But if you want:
From the command line:
env > /tmp/env.norm.txt
Take what you need from there and past it into the script that cron is running.
PATH and TERM are critical. stty -a those settings may matter as well.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2007 06:49 PM
09-06-2007 06:49 PM
Re: top not running from cron entry..............
POINTS GIVEN