Shell controls the number of running times (based on the date)

Source: Internet
Author: User

Shell controls the number of running times (based on the date) many people worry that due to time issues or misoperations, the script runs multiple times (especially data operations ). Therefore, it is necessary to add some control. Similarly, if you need to control the number of times, you can add the number field. The following is an example of how to modify it according to the running scenario. Update () {date_d = 'date "+ % Y-% m-% d" 'echo "$ date_d"> run_fileecho "update complete, write the date to the run_file file (marked as running on a single day) "} run_check () {if [-f run_file]; then run_date = 'awk' END {print $0} 'run_file 'if [$ run_date = $ date_d]; then echo "$ date_d has been run once, exit "exit 0 else echo" $ date_d without running records. Call update to run "update fi else update fi} main () {run_check} main

Related Article

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.