- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Quick Script Question: Waiting for a (period)
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
01-29-2002 05:18 AM
01-29-2002 05:18 AM
I need a method of setting a pause from within a script, other than sleep. I want to be able to wait for a random amount of time betweet 0 and 1 sec.
Does anyone have a reliable non hardware dependant solution ?
All tips, pointers, RTFF's , RTFM's warmly received as ever !!
Cheers,
-ChaZ-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 05:25 AM
01-29-2002 05:25 AM
Re: Quick Script Question: Waiting for a (period)
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 05:29 AM
01-29-2002 05:29 AM
Re: Quick Script Question: Waiting for a (period)
With perl:
perl -e "select(undef,undef,undef,\$ARGV[0]);" n
will work for fractional values of n.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 05:30 AM
01-29-2002 05:30 AM
Re: Quick Script Question: Waiting for a (period)
Look at script and check, whether you can use it :
today_=`date +'%y-%m-%d'`; export today_
#
LOG1=/usr/tmp/cpio_${today_}.1st; export LOG1
#
PATH=$PATH:/usr/local/bin
export PATH
exec > /usr/tmp/cpio_${today_}.log 2>&1
#
#
find / -depth -print | cpio -ocBv > /dev/rmt/0m 2>> ${LOG1} &
first_cpio=$!; export first_cpio
#
wait $first_cpio
if test $? -ne 0; then
echo "Full Offline Backup did not complete successfully!"
fi
echo "Time is: `/bin/date`"
echo "Time is: `/bin/date`"
echo "Time is: `/bin/date`" >> ${LOG1}
--------------------
Rgds
Alexander M. Ermes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 05:33 AM
01-29-2002 05:33 AM
Re: Quick Script Question: Waiting for a (period)
Might help if I read the question - this will give you a random sleep between 0 and 1 secs:
perl -e "srand;select(undef,undef,undef,rand);"
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 05:37 AM
01-29-2002 05:37 AM
Re: Quick Script Question: Waiting for a (period)
I really need something available from the shell even if it's not very accurate. I've tried loops etc, but I don't really want to write code that hammers the server into making a delay.
Any other thoughts ?
Thanks again!
-ChaZ-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:07 AM
01-29-2002 06:07 AM
Re: Quick Script Question: Waiting for a (period)
I guess you could just ran a command that doesn't do anything except take up time.
something like
echo "do nothing" > /dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:17 AM
01-29-2002 06:17 AM
Re: Quick Script Question: Waiting for a (period)
snip:
#!/usr/bin/sh
# scroll
# Don't ask.
typeset -i x=0
strg_len=$(echo "$*" | wc -m)
clear
while (( x < $strg_len )) && (( $strg_len < 1024 ))
do
(( x = x + 1 ))
scroll[x]=`echo "$*" |cut -c $x`
print "${scroll[x]}\c"
sleep 1
done
tput cud1
Cheers,
-ChaZ-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:22 AM
01-29-2002 06:22 AM
Re: Quick Script Question: Waiting for a (period)
You have a fundamental problem in that sleep has second resolution. However, there is a system call, nanosleep, which has much finer resolution. You could write a very small C program which nanosleeps for an amount of time based upon the random parameter passed in by the calling process - your shell script. The entire C program would be at most 20 lines of code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:43 AM
01-29-2002 06:43 AM
Re: Quick Script Question: Waiting for a (period)
Could someone point me in the right direction?
Cheers,
-ChaZ-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 07:00 AM
01-29-2002 07:00 AM
Re: Quick Script Question: Waiting for a (period)
Here is my 2 minute C program. Use it like this: nanosleep 4500 to cause a 4500 msec delay or nanosleep 750 to cause a 750msec delay.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 07:27 AM
01-29-2002 07:27 AM
Re: Quick Script Question: Waiting for a (period)
Here's one that gives you random tenths of a second delays:
#include
#include
int main()
{
int m;
srand((unsigned long)time(NULL));
m = 100000*(int) (10.0*rand()/(RAND_MAX+1.0));
/* printf("%d\n",m); */
usleep(m);
return 0;
}
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2002 01:36 AM
01-30-2002 01:36 AM
Re: Quick Script Question: Waiting for a (period)
I'll get compiling later today and make sure everything's okay.
Cheers!
-ChaZ-