README.md 5.39 KB
Newer Older
Tim Smith's avatar
Tim Smith committed
1
# cron Cookbook
Tim Smith's avatar
Tim Smith committed
2

Lance Albertson's avatar
Lance Albertson committed
3 4 5 6 7
[![Cookbook Version](https://img.shields.io/cookbook/v/cron.svg)](https://supermarket.chef.io/cookbooks/cron)
[![CI State](https://github.com/sous-chefs/cron/workflows/ci/badge.svg)](https://github.com/sous-chefs/cron/actions?query=workflow%3Aci)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
Tim Smith's avatar
Tim Smith committed
8

jtimberman's avatar
jtimberman committed
9
Installs the cron package and starts the crond service.
10

11 12
Note: Chef 14.4 shipped with the cron_d and cron_access (cron_manage) resources. When Chef 15.4 ships in Aug 2019 these resources will be removed from this cookbook as all users should be on Chef 14.4 or later.

Lance Albertson's avatar
Lance Albertson committed
13 14 15 16
## Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).

Tim Smith's avatar
Tim Smith committed
17
## Requirements
Tim Smith's avatar
Tim Smith committed
18

Tim Smith's avatar
Tim Smith committed
19
### Platforms
Tim Smith's avatar
Tim Smith committed
20

Seth Vargo's avatar
Seth Vargo committed
21 22
- RHEL family
- Debian family
Cam Cope's avatar
Cam Cope committed
23
- Solaris family
Craig Lewis's avatar
Craig Lewis committed
24
- FreeBSD
25
- SUSE family
26

Tim Smith's avatar
Tim Smith committed
27
### Chef
Tim Smith's avatar
Tim Smith committed
28

29
- Chef 12.7+
Tim Smith's avatar
Tim Smith committed
30

Tim Smith's avatar
Tim Smith committed
31
### Cookbooks
Tim Smith's avatar
Tim Smith committed
32

33
- none
Tim Smith's avatar
Tim Smith committed
34

Tim Smith's avatar
Tim Smith committed
35
## Resources
Tim Smith's avatar
Tim Smith committed
36

Seth Vargo's avatar
Seth Vargo committed
37
### `cron_d`
Tim Smith's avatar
Tim Smith committed
38

39
The `cron_d` custom resource can be used to manage files in `/etc/cron.d`. It supports the same interface as Chef's built-in `cron` resource:
Seth Vargo's avatar
Seth Vargo committed
40

41
#### Properties
Tim Smith's avatar
Tim Smith committed
42

43
- `cron_name` - Set the name of the cron job. If this isn't specified we'll use the resource name.
Lance Albertson's avatar
Lance Albertson committed
44
- `minute`, `hour`, `day`, `month`, `weekday` - schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "\*".
Tim Smith's avatar
Tim Smith committed
45
- `predefined_value` - schedule your cron job with one of the special predefined value instead of _**_ * pattern. This correspond to `"@reboot"`, `"@yearly"`, `"@annually"`, `"@monthly"`, `"@weekly"`, `"@daily"`, `"@midnight"` or `"@hourly"`.
Tim Smith's avatar
Tim Smith committed
46 47
- `command` - the command to run. Required.
- `user` - the user to run as. Defaults to "root".
48
- `mailto`, `path`, `home`, `shell`, `random_delay` - set the corresponding environment variables in the cron.d file. No default.
Tim Smith's avatar
Tim Smith committed
49
- `environment` - a Hash containing additional arbitrary environment variables under which the cron job will be run (similar to the `shell` LWRP). No default.
Tim Smith's avatar
Tim Smith committed
50
- `comment` - A comment to place in the cron.d file
51
- `mode` - the octal mode of the generated crontab file. Defaults to `0600`.
Tim Smith's avatar
Tim Smith committed
52

53 54 55 56 57 58 59 60 61 62 63
#### Examples

```ruby
cron_d 'daily-usage-report' do
  minute  0
  hour    23
  command '/srv/app/scripts/daily_report'
  user    'appuser'
end
```

64 65 66 67 68 69 70 71 72 73
```ruby
cron_d 'Setup the daily usage cron job' do
  cron_name 'daily-usage-report'
  minute  0
  hour    23
  command '/srv/app/scripts/daily_report'
  user    'appuser'
end
```

74
### `cron_access`
Tim Smith's avatar
Tim Smith committed
75

76
The `cron_access` resource can be used to manage the `/etc/cron.allow` and `/etc/cron.deny` files.
Tim Smith's avatar
Tim Smith committed
77

78 79 80 81 82 83
Note: This resource was previously a Chef definition cron_manage. The legacy name will still function, but should be updated.

#### Actions

- `:deny` - Add the user to the cron.deny file (default).
- `:allow` - Add the user to the cron.allow file.
84

85 86
#### Properties

87
- `user` - username that you want to control. If not provided the resource name will be used as the user.
88 89 90

#### Examples

91 92 93
The following will add the user mike to the `/etc/cron.allow` file:

```ruby
94
cron_access 'mike' do
95 96 97 98 99 100 101
  action :allow
end
```

The following will add the user john to the `/etc/cron.deny` file:

```ruby
102 103
cron_access "Make sure john can't touch cron" do
  user 'john'
104 105 106 107
  action :deny  #optional, deny is the default
end
```

Lance Albertson's avatar
Lance Albertson committed
108
## Contributors
Seth Vargo's avatar
Seth Vargo committed
109

Lance Albertson's avatar
Lance Albertson committed
110
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
111

Lance Albertson's avatar
Lance Albertson committed
112
### Backers
113

Lance Albertson's avatar
Lance Albertson committed
114
Thank you to all our backers!
115

Lance Albertson's avatar
Lance Albertson committed
116
![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)
117

Lance Albertson's avatar
Lance Albertson committed
118
### Sponsors
119

Lance Albertson's avatar
Lance Albertson committed
120 121 122 123 124 125 126 127 128 129 130 131
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)