Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kvz committed Jun 26, 2012
1 parent fc97033 commit 94a4462
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,4 +1,4 @@
Copyright (c) 2012 Kevin van Zonneveld
Copyright (c) 2012 Kevin van Zonneveld (http://twitter.com/kvz || http://kevin.vanzonneveld.net)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
23 changes: 9 additions & 14 deletions README.md
Expand Up @@ -55,12 +55,11 @@ to change the behavior of cronlock:

- `CRONLOCK_HOST` the Redis hostname. default: `localhost`
- `CRONLOCK_PORT` the Redis port. default: `6379`
- `CRONLOCK_GRACE` determines how long a lock should at least persist. default is 40s: `40`
This is too make sure that if you have a very small job, and clocks aren't in sync, the same job
on server2 (slightly behind in time) will just fire right after server1 finished it
I recommend using a grace of at least 30s
- `CRONLOCK_RELEASE` determines how long a lock can persist at most.
acts as a failsafe so there can be no locks that persist forever in case of failure. default is a day: `86400`
- `CRONLOCK_GRACE` determines how many seconds a lock should at least persist.
This is to make sure that if you have a very small job, and clocks aren't in sync, the same job
on server2/3/4/5/6/etc (maybe even slightly behind in time) will just fire right after server1 releases the lock. default: `40` (I recommend using a grace of at least 30s)
- `CRONLOCK_RELEASE` determines how long a lock can persist at most.
Acts as a failsafe so there can be no locks that persist forever in case of failure. default is a day: `86400`
- `CRONLOCK_KEY` a unique key for this command in the global Redis server. default: a hash of cronlock's arguments
- `CRONLOCK_PREFIX` Redis key prefix used by all keys. default: `cronlock`
- `CRONLOCK_VERBOSE` set to `yes` to print debug messages. default: `no`
Expand Down Expand Up @@ -113,7 +112,7 @@ crontab -e
* * * * * cronlock ls -al # will use config from /etc/cronlock.conf
```

### Lock commands with different arguments
### Lock commands even though they have different arguments

By default cronlock uses your command and it's arguments to make a unique identifier
by which the global lock is acquired. However if you want to run: `ls -al` or `ls -a`,
Expand All @@ -132,13 +131,9 @@ One ls will be excecuted for app1, and one for app2.

```bash
crontab -e
# One of two will be executed because they share the same KEY accross 1 PREFIX
* * * * * CRONLOCK_PREFIX="app1" CRONLOCK_KEY="ls" cronlock ls -al
* * * * * CRONLOCK_PREFIX="app1" CRONLOCK_KEY="ls" cronlock ls -a

# One of two will be executed because they share the same KEY accross 1 PREFIX
* * * * * CRONLOCK_PREFIX="app2" CRONLOCK_KEY="ls" cronlock ls -al
* * * * * CRONLOCK_PREFIX="app2" CRONLOCK_KEY="ls" cronlock ls -a
# Both /var/www/mail_customers.sh will run, because they have the application in their prefixes
* * * * * CRONLOCK_PREFIX="app1" cronlock /var/www/mail_customers.sh
* * * * * CRONLOCK_PREFIX="app2" cronlock /var/www/mail_customers.sh
```

## Exit codes
Expand Down
4 changes: 4 additions & 0 deletions cronlock
Expand Up @@ -6,6 +6,10 @@
# Copyright 2012 by Kevin van Zonneveld (http://kevin.vanzonneveld.net)
# Contains code from https://github.com/reinh/redis.bash
#
# License:
# - web: https://github.com/kvz/cronlock/blob/master/LICENSE.txt
# - cli: curl https://raw.github.com/kvz/cronlock/master/LICENSE.txt
#
# Readme:
# - web: https://github.com/kvz/cronlock/blob/master/README.md
# - cli: curl https://raw.github.com/kvz/cronlock/master/README.md
Expand Down

0 comments on commit 94a4462

Please sign in to comment.