- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: execute cronjob @ 10 second intervals ?
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
тАО06-29-2004 09:56 AM
тАО06-29-2004 09:56 AM
*********************************
HP-UX B.11.11 U 9000/800/N4000-75
*********************************
I'm trying to find a way to execute a cronjob
with 10 seconds intervals ? I know it can be
executed at minute intervals.
The (2) commands I have in a script gather information related to "free memory & cpu info" are as follows:
1)/usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
2)/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
Please advised if this is possible, as always
thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2004 10:05 AM
тАО06-29-2004 10:05 AM
SolutionI dont think it is possible with cron.
Alternate way is to write a script
#!/usr/bin/sh
while true
do
/usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }' >> /tmp/vmstat1.out
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}' >> /tmp/vmstat2.out
sleep 10
done
run the script with nohup and in the backup
# nohup /usr/local/bin/
Sundar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2004 10:15 AM
тАО06-29-2004 10:15 AM
Re: execute cronjob @ 10 second intervals ?
simplest is to use "sleep n" command where machine will wait doing nothing in a a script for n-seconds when it hits this command, but it does not actually make running your command every 10 seconds. it will be 10 seconds between two command executions plus how ever many seconds the command needs to run.
to accomplish running your commands every 10 seconds you can use a construct like this :
while true
do
chkstr=`date +%S` # will give you the seconds from the date string
case "$chkstr" in
00) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
10) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
20) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
30) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
40) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
50) /usr/bin/vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
/usr/bin/vmstat -n 1 1 | tail -9 | awk '{print $1,$2,$3}'
break ;;
*) sleep 1
break ;;
esac
done
Hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2004 10:27 AM
тАО06-29-2004 10:27 AM
Re: execute cronjob @ 10 second intervals ?
while true
do
SECS=$(date +%S)
case "$SECS" in
[0-5]0)
sleep 1
;;
*) continue ;;
esac
done
I am not sure if a loop will executed only once in a second !! , so I included a sleep right after the case statement and not in the default section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2004 10:29 AM
тАО06-29-2004 10:29 AM
Re: execute cronjob @ 10 second intervals ?
Since you have vmstat commands, you dont need a sleep in the case statements and can aswell have it in the default section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 04:30 AM
тАО07-01-2004 04:30 AM
Re: execute cronjob @ 10 second intervals ?
Looks like what you really want is realtime vmstat information.
You could do what you want by changing your method.
Let say you want 10 second data between 8 and 5 daily or 9 hours of 10 second data during prime time.
kick off you cron shellb at 08:00
The shell would look something like:
/usr/bin/vmstat 10 3240 |awk '($0 !~ /p/) {printf "%d%s\n", ($5*4)/1024, "MB" }' >> logfile
the 3240 is how many 10 second intervals in 9 hours. You cauld tail or look at the logfile. and get the most current value.
Also this will give you less overhead of trying to start a cron job a bunch of time.
Why sleep 10 when vmstat has the parm
the $0 !~ /p/ is a way to remove the header
with thought you probably think of something better.
Rory