Sponsored Content
Full Discussion: Avoiding "file collision"
Top Forums UNIX for Dummies Questions & Answers Avoiding "file collision" Post 302391244 by treesloth on Sunday 31st of January 2010 12:45:42 PM
Old 01-31-2010
Thanks for the reply. To answer your questions, the goal of the script is to test MySQL responsiveness on a server that is showing very strange unresponsiveness. So, the script sends $1 queries to the db, waiting $2 seconds between queries. Most of my requests are simultaneous, with $2 == 0, but I wanted the ability to add a little delay (usually .1 or .2, give or take).

As for your question about wait, the answer is simple... I didn't know it existed. :-) I'd considered the possibility of writing to, then combining, files but didn't know how to get the script to wait until bg processes were finished. So, I read about that and worked it in. Thanks for the pointer. While I was at it, I made a couple of other minor improvements.

Code:
#!/usr/local/bin/bash

ts=$(date +%m%d%y_%H%M%S)
printf '\n\n'"#####"$ts" :: Iterations:"$1" :: Delay:"$2'\n' >> /tmp/mysql_times

for num in `jot $1`   ##  Yep, jot... this is FreeBSD
do
printf "\rSpawning query process "$num" of "$1
/usr/bin/time -a -o /tmp/.tmp_mysql_times_$num mysql --user=root --password=password -e "USE test ; SELECT quote FROM table ORDER BY RAND() LIMIT 1;" > /dev/null &
sleep $2
done

printf "\nWaiting..."
wait

awk '{split(FILENAME,a,"__") ; print a[2] " :: \t" $0}' /tmp/.tmp_mysql_times__* >> /tmp/mysql_times && rm /tmp/.tmp_mysql_times_*

printf "\nDone\n\n"


Last edited by treesloth; 01-31-2010 at 02:25 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

5. Windows & DOS: Issues & Discussions

Avoiding DOS space related "path not found errors"

Well I have a lot of scripts that require dragging and dropping files in order to define Source files etc. However more often then not it is the case that the path to said file contains NUMEROUS spaces. I know one way to evade this problem is to encase the path in Quotes like this: ... (7 Replies)
Discussion started by: pasc
7 Replies

6. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

7. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

8. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
__gnu_pbds::sample_resize_policy(3)			     Library Functions Manual			       __gnu_pbds::sample_resize_policy(3)

NAME
__gnu_pbds::sample_resize_policy - SYNOPSIS
Public Types typedef std::size_t size_type Public Member Functions sample_resize_policy () sample_range_hashing (const sample_resize_policy &other) void swap (sample_resize_policy &other) Protected Member Functions size_type get_new_size (size_type size, size_type num_used_e) const bool is_resize_needed () const void notify_cleared () void notify_erase_search_collision () void notify_erase_search_end () void notify_erase_search_start () void notify_erased (size_type num_e) void notify_find_search_collision () void notify_find_search_end () void notify_find_search_start () void notify_insert_search_collision () void notify_insert_search_end () void notify_insert_search_start () void notify_inserted (size_type num_e) void notify_resized (size_type new_size) Detailed Description A sample resize policy. Definition at line 47 of file sample_resize_policy.hpp. Member Typedef Documentation typedef std::size_t __gnu_pbds::sample_resize_policy::size_type Size type. Definition at line 51 of file sample_resize_policy.hpp. Constructor &; Destructor Documentation __gnu_pbds::sample_resize_policy::sample_resize_policy () Default constructor. Member Function Documentation size_type __gnu_pbds::sample_resize_policy::get_new_size (size_typesize, size_typenum_used_e) const [protected] Queries what the new size should be. bool __gnu_pbds::sample_resize_policy::is_resize_needed () const [inline], [protected] Queries whether a resize is needed. void __gnu_pbds::sample_resize_policy::notify_cleared () [protected] Notifies the table was cleared. void __gnu_pbds::sample_resize_policy::notify_erase_search_collision () [inline], [protected] Notifies a search encountered a collision. void __gnu_pbds::sample_resize_policy::notify_erase_search_end () [inline], [protected] Notifies a search ended. void __gnu_pbds::sample_resize_policy::notify_erase_search_start () [inline], [protected] Notifies a search started. void __gnu_pbds::sample_resize_policy::notify_erased (size_typenum_e) [inline], [protected] Notifies an element was erased. void __gnu_pbds::sample_resize_policy::notify_find_search_collision () [inline], [protected] Notifies a search encountered a collision. void __gnu_pbds::sample_resize_policy::notify_find_search_end () [inline], [protected] Notifies a search ended. void __gnu_pbds::sample_resize_policy::notify_find_search_start () [inline], [protected] Notifies a search started. void __gnu_pbds::sample_resize_policy::notify_insert_search_collision () [inline], [protected] Notifies a search encountered a collision. void __gnu_pbds::sample_resize_policy::notify_insert_search_end () [inline], [protected] Notifies a search ended. void __gnu_pbds::sample_resize_policy::notify_insert_search_start () [inline], [protected] Notifies a search started. void __gnu_pbds::sample_resize_policy::notify_inserted (size_typenum_e) [inline], [protected] Notifies an element was inserted. void __gnu_pbds::sample_resize_policy::notify_resized (size_typenew_size) [protected] Notifies the table was resized to new_size. __gnu_pbds::sample_resize_policy::sample_range_hashing (const sample_resize_policy &other) Copy constructor. void __gnu_pbds::sample_resize_policy::swap (sample_resize_policy &other) [inline] Swaps content. Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ Tue Jun 10 2014 __gnu_pbds::sample_resize_policy(3)
All times are GMT -4. The time now is 07:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy