-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
78 lines (53 loc) · 2.46 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
written by : Stephen J. Friedl
Software Consultant
Southern California USA
http://www.unixwiz.net/tools/
===================================================================
======== This software is in the public domain, and can be ========
======== used by anybody for any purpose ========
===================================================================
Lockrun: This program is used to launch a program out with a lockout
so that only one can run at a time. It's mainly intended for use out
of cron so that our five-minute running jobs which run long don't get
walked on. We find this a *lot* with Cacti jobs which just get hung
up: it's better to miss a polling period than to stack them up and
slow each other down.
So we use a file which is used for locking: this program attempts to
lock the file, and if the lock exists, we have to either exit with
an error, or wait for it to release.
lockrun --lockfile=FILE -- my command here
COMMAND LINE
------------
--lockfile=F
Specify the name of a file which is used for locking. The file is
created if necessary (with mode 0666), and no I/O of any kind is
done. The file is never removed.
--maxtime=N
The script being controlled should run for no more than <N> seconds,
and if it's beyond that time, we should report it to the standard
error (which probably gets routed to the user via cron's email).
--wait
When a lock is hit, we normally exit with error, but --wait causes
it to loop until the lock is released.
--sleep=N
When using --wait, will sleep <N> seconds between attempts to acquire
the lock.
--retries=N
When using --wait, will try only <N> attempts of acquiring the lock.
--verbose
Show a bit more runtime debugging.
--quiet
Don't show "run is locked" error if things are busy; keeps cron from
overwhelming you with messages if lockrun overlap is not uncommon.
--
Mark the end of the options: the command to run follows.
VERSION HISTORY
1.1.3 2014/11/03; now handle exit status correctly (thanks to Richard Faasen)
1.1.2 2013/04/26; now we use lockf() if the platform supports it
1.1.1 2012/09/05; added setsid() to make the controlled process a process
group leader
1.1.0 2012/09/05; added --version and --help; added --retries (thanks Dov Murik)
1.0.3 2010/11/20; added --quiet parameter
1.0.2 2009/06/25; added lockf() support for Solaris 10 (thanks Michal Bella)
1.0.1 2006/06/03; initial release