Use scripting to improve productivity

Source: Internet
Author: User

Scripting language can reduce a lot of manual operation, as a Linux programmer should understand the simple script to replace the manual operation, I also long ago to learn a lot of scripts, probably more than a year has not written, now only remember some basic grammar.

To talk about my needs, I wrote a loop queue interface, and then wrote a test program to test the loop queue, and now I want the test program to execute a number of times to see if there is a segment error (resulting in a core file) to test the stability of the loop queue interface.

The program now executes the directory input ulimit-c Unlimited to make the program produce a segment error when you can produce a core file for debugging later.

A simple procedure for scripting is attached below.

1. Script to start the test program (RUNQUEUE.SH)

The purpose of this script is: As long as the queue program exits on startup, execute 50 times

1 #!/bin/bash23for1; C + +))4do       5         'runqueue shell start ' ; 6         . /Queue7done     

2. The script that kills the test program (KILLQUEUE.SH) has been tested to find that the queue process has been executed for about three minutes, so the killqueue.sh cycle sleep time is set to 4 minutes.

The purpose of this script is: Kill the queue program every 4 minutes, execute 50 times

 1  #!/bin/bash  2  3  for  ((c = 1 ; C <= 50 ; C++ 4   Do  5  echo  " kill Queue shell start   " 6  Sleep Span style= "color: #800080;" >240  7  8  kill-9   pidof queue '  9  done 

The reason I don't write two scripts is because when I write a script I find that the command to kill the process after the script starts the test program is unsuccessful, automatically switches to the queue process, and the script no longer executes the subsequent statements.

Use scripting to improve productivity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.