lockfile

Read about lockfile, The latest news, videos, and discussion topics about lockfile from alibabacloud.com

Use File::lockfile in Perl to ensure that a script instance runs _perl

Write some monitoring scripts in Perl and put them in crontab to schedule execution. It is sometimes found that a script runs too long and runs multiple instances at the same time, so it is necessary to control the script and run only one instance. The simplest natural idea is to check and create an empty lock file in the script and delete it at the end of the script. Determine whether the script is running by determining the existence of the file. However, there is a bug that if the script run

[Go] (Multi-instance) Mysql-mmm cluster

startup script) 1 #!/bin/sh 2 # Chkconfig:-3 # description:mmm Agent. 4 # processname:mmm_agentd 5 # Config:/etc/mysql-mmm/mmm_agent.conf 6 # Pidfile:/var/run/mysql-mmm/mmm_agentd.pid 7 # S Ource function library and defaults file. 8. /etc/rc.d/init.d/functions 9. /etc/default/mysql-mmm-agent10 # Cluster Name (it can be empty for default cases) one cluster= ' navy2 ' lockfile= '/var/lock/ Subsys/mysql-mmm-agent_navy2 ' prog= ' mmm Agent Daemon ' #---

How to write a robust bash script (experience sharing) _linux Shell

-triggered when someone kills a script process using kill EXITExit-This is a pseudo signal that is triggered when the script exits normally or after set-e because of an error When you use a lock file, you can write this: Copy Code code as follows: if [!-e $lockfile]; Then Touch $lockfile Critical-section RM $lockfile Else echo "Critic

Shell Programming Case Statements

statements:Case $VARAIBLE inPAT1)Branch 1;;PAT2)Branch 2;;...*)Branch N;;EsacCase supports GLOB-style wildcard characters:*: Any character of any length;?: any single character;[]: Any single character in the range;A|b:a or B;Example: Write a service framework script;$lockfile, Value/var/lock/subsys/script_name(1) This script can accept start, stop, restart, status of one of the four parameters;(2) If the parameter is not four, then the use of help a

Write a summary of some tips for robust bash shell scripts _linux shell

to a known state when the script encounters a problem, you are great. Fortunately, Bash provides a way to run a command or a function when bash receives a UNIX signal. You can use the Trap command. Copy Code code as follows: Trap command signal [signal ...] You can link multiple signals (lists can be obtained using kill-l), but in order to clean up the mess, we use only three of them: Int,term and exit. You can use-as to get the traps back to its original state. Signa

Summary of L7.3 Loop statements

function codeCall after: give the function name and pass the parameters on demandDefine the method:(1) Function F_name {function body}(2) F_name () {function body}Call Function:F_name [Argu1, ARGU2, ...]Custom function state return value:return [#]0: Success1-255: FailureNote: When the function code executes, once the return is encountered, the function code terminates and the function returns;Example: Execute start,stop,restart to implement the file state judgment separately:The Start,stop,res

Data in Expect_out (buffer) that contains send

data in Expect_out (buffer) that contains send I always thought that once the send is executed in expect, expect_out (buffer) is emptied until new data is filled in, which is exactly what is used in the expect statement. And today in debugging, I was surprised to find the problem, the original expect_out (buffer) will not be automatically emptied, and expect to the data is probably not what you really want, very likely is historical data. This issue is also noted in the article "Expect_out (buff

Write robust Bash scripts

only use three of them: INT, TERM, and EXIT. You can use-as to restore traps to the initial state. Signal description INT Interrupt-the TERM Terminate is triggered when someone uses Ctrl-C to Terminate the script-the EXIT Exit is triggered when someone uses kill to kill the script process-this is a pseudo signal, it is triggered when the script exits normally or after set-e exits due to an error. when you use the lock file, you can write: if [! -E $ lockfil

Write a robust bash script

-triggered when someone kills a script process using killEXITExit-This is a pseudo-signal that is triggered when the script exits normally or after a set-e because of an errorWhen you use the lock file, you can write this:if [!-e $lockfile]; ThenTouch $lockfileCritical-sectionRM $lockfileElseecho "Critical-section is already running"FiWhen the most important part (Critical-section) is running, what happens if the script process is killed? The lock fil

Perl lets script single instances run with file locks

file::lockfile, File::P ID, Proc::P id::file , etc. Here is an example of file::lockfile, which is very simple: Here is the code snippet: 01 #!/usr/bin/perl-w 02 Usefile::lockfile; 03 # lock file is located in the/tmp directory, named Test_file_lock.lck 04 My $

Perl uses file locks to run a single script instance

complete the above functions, suchFile: lockfile,File: PID,Proc: PID: File. The following is an example of file: lockfile, which is very simple: Below isCodeFragment: 01 #! /Usr/bin/perl-W 02 UseFile: lockfile; 03 # The lock file is located in the/tmp directory named test_file_lock.lck

Single-instance process generation scheme in UNIX environment

In some cases, a process can only generate one instance for execution. In a Unix environment, the file-and record-locking mechanisms are provided, and basic solutions for single-instance processes are provided.Assume that a process generates a file when it starts to run, and locks the entire file, and only one of these write locks can be generated.If the subsequent process tries to generate a write lock, it will fail. This implies that the previous instance is running. The following method det

Write robust Bash scripts

when the script Exits normally or after set-e exits due to an error. When you use the lock file, you can write: if [! -E $ lockfile]; thentouch $ lockfilecritical-sectionrm $ lockfileelseecho "critical-section is already running" fi when the most important part (critical-section) is running, what happens if the script process is killed? The lock file will be thrown there, and your script will no longer run until it is deleted. Solution: if [! -E $

---------Linux Script Programming---until,for,case

once, how to handle 4) stop, delete/var/lock/subsys/script_name, and display "Stop complete" consider: if it has stopped beforehand, how to deal with it? 5) Restart, stop, then start to consider : If there is no start, how to handle 6) How is the Status,/var/lock/subsys/script_name file exists, then displays "Script_nameisrunning ..."/var/ Lock/subsys/script_name file does not exist, it displays "script_nameisstopped ..." Where: Script_name is the current script name. $0#!/bin/bash#chkconfig:-8

Tomcat installation +nginx reverse proxy tomcat+apache using Mod_jk+mod_proxy reverse proxy and load Balancing "diagram"

configuration. . /etc/sysconfig/network # Check that networking are up. ["$NETWORKING" = "no"] exit 0 nginx= "/usr/sbin/nginx" prog=$ (basename $nginx) Nginx_conf_file= "/etc/nginx/nginx.conf" [-f/etc/sysconfig/nginx] . /etc/sysconfig/nginx Lockfile=/var/lock/subsys/nginx Make_dirs () { # Make required Directories User= ' Nginx-v 2>1 | grep "Configure arguments:" | Sed ' s/[^*]*--user=\ ([^]*\). */\1/g '-' Options= ' $nginx-v 2>1 | grep

GRAYLOG2+SYSLOG-NG+MONGODB Building Centralized Management log server--reprint

/shirdrn/article/details/71055392. Provide service startup scripts for MongoDB and startClick (here) to collapse or open #vim/etc/init.d/mongod #内容如下 ———————————————————————————————— #!/bin/bash # Chkconfig:-90 11 # DESCRIPTION:MONGODB Server SysV Script . /etc/rc.d/init.d/functions if [-f/etc/sysconfig/mongod]; Then . /etc/sysconfig/mongod Fi Mongod=/usr/local/mongodb/bin/mongod Prog=mongod Lockfile=/data/db/mongod.lock

Function of Shell programming

"No such user."Fi}Username=$1UserInfoUsername=$2UserInfoExample 2: Service scripting framework#!/bin/bash## Chkconfig:-50 50# description:test Service Script#prog=$ (basename)lockfile=/var/lock/subsys/$progStart () {If [-f $lockfile]; Thenecho "$prog is running yet."ElseTouch $lockfile[$?-eq 0] echo "Start $prog finshed."Fi}Stop () {If [-f $

My experience in running Docker on Mesos

, resulting in file corruption. Here is the code I wrote for The Docker container to process the file system lock: #! /Bin/bash # The location the lock will be attempted in LOCKROOT = "/minecraft/lock" LOCKDIRNAME = "lock" LOCKFILENAME = "mylock. lck" # This is the command to run if we get the lock. RUNCMD = "./start. sh" # Number of seconds to consider the Lock stale, this cocould be application dependent. LOCKTIMEOUT = 60 SLEEPLOOP = 30 LOCKDIR =$ {LOCKROOT}/$ {LOCKDIRNAME}

PHP enables active and passive updates in chat rooms

. please contact us if you have any questions"); } 2. initialize the information and enter the chat room for the first time. If ($ action = "enter ") { //////////////// Call the js program that displays the home screen ////////////// ////// Print ("parent. write2 (); n "); // The Speech Content. xx entered the chat room $ Message = "$ name Go to the chat room ". $ message." ". date (" m Month d h: I ")." script parent. add ('$ name ', '$ Photo'); parent. write1 (); script "; } // Update the

Mongodb service script writing

mongod file in the/etc/init. d directory The content is as follows: #!/bin/sh##mongod - Startup script for mongod## chkconfig: - 85 15# description: Mongodb database.# processname: mongod# Source function library. /etc/rc.d/init.d/functions# things from mongod.conf get there by mongod reading it# OPTIONSOPTIONS=" -f /etc/mongod.conf"#mongodmongod="/root/mongodb/bin/mongod"lockfile=/var/lock/subsys/mongodstart(){ echo -n $"Starting mongod: " daemon

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

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.