-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.1
109 lines (109 loc) · 2.49 KB
/
single.1
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
.\" Copyright (c) 2016 Dmitrij D. Czarkoff
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: September 19 2016$
.Dt SINGLE 1
.Os
.Sh NAME
.Nm single
.Nd run program once at a time
.Sh SYNOPSIS
.Nm
.Op Fl hvw
.Op Fl d Ar dir
.Op Fl f Ar file
.Op Fl r Ar sec
.Op Fl t Ar sec
.Ar command
.Sh DESCRIPTION
.Nm
runs a comman and creates a lock, so that consequent attempts to run the same
program using
.Nm
will fail until command exits.
.Pp
The following flags are available:
.Bl -tag -width indent
.It Fl d Ar dir
Create lock file in
.Pa dir .
.It Fl f Ar file
Use
.Pa file
for name of lock file.
If used with
.Fl d ,
.Pa file
is placed in
.Pa dir .
By default,
.Nm
uses first word from the
.Ar command
arguments for the name of the lock.
.It Fl r Ar sec
Sleep for random amount of seconds between 0 and
.Ar sec
before executing command.
.It Fl t Ar sec
Sleep for
.Ar sec
seconds before executing command.
.It Fl w
If
.Ar command
is already locked, wait until the lock file is unlink and then continue as if
there was no lock.
Without this option
.Nm
will exit if lock file is found.
.It Fl v
Verbosely report locking status.
If
.Ar command
is alreadly locked,
this flag causes
.Nm
to report the fact and the time when the lock was acquired.
In combination with
.Fl w
flag, it also causes
.Nm
to report when the lock is released.
.It Fl h
Print usage information and exit.
.El
.Pp
Unless
.Ar command
is already locked, remaining arguments are passed to the operating system.
.Pp
If both
.Dq Fl r
and
.Dq Fl t
flags are used, respective delays are added up.
.Sh CAVEATS
.Nm
provides no way to examine exit status of
.Ar command .
.Pp
When multiple
.Nm
instances wait on a lock. no queuing occurs.
There is no way to predict which instance of
.Nm
will run after the lock is released.
.Sh AUTHOR
.An Dmitrij D. Czarkoff Aq [email protected] .