Skip to content

Commit

Permalink
readme updated to include cron and systemd configuration examples
Browse files Browse the repository at this point in the history
Signed-off-by: zerjioang <zerjioang@users.noreply.github.com>
  • Loading branch information
zerjioang committed Oct 21, 2021
1 parent 88b9313 commit 74dbdd3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Previous command will try to update the DNS A Record of `rpi.example.com` with t
* **X_CF_AGENT_ZONE**: name of the DNS zone you want to edit
* **X_CF_AGENT_DNS_A_RECORD**: name of the DNS Record name you want to edit.

## Configure autostart
## Start modes

### Using systemd autostart
### Option 1: Using systemd autostart

Edit the ddns-cloudflare.service file and move it to `/etc/systemd/system/`, then run:

Expand All @@ -81,6 +81,49 @@ sudo systemctl daemon-reload
sudo systemctl enable ddns-cloudflare
sudo systemctl start ddns-cloudflare
```

### Option 2: Using cron

Access to your cron file with `crontab -e` and add the following content. For example, in order to update the device IP eery 10 minutes you need to add

```bash
# run a Cloudflare DDNS updater each 10 minutes
*/10 * * * * /opt/ddns-cloudflare update
```

You can verify the content of the with `crontab -l`. Your new line in the crontab file should look like

```bash
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command

# run a Cloudflare DDNS updater each 10 minutes
*/10 * * * * /opt/ddns-cloudflare update
```

I recommend you to use https://crontab.guru/ if you want to easily configure the crontab timing

## Troubleshooting

### API Token must not be empty
Expand Down
4 changes: 2 additions & 2 deletions cfagent.service → ddns-cloudflare.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ After=network.target

[Service]
Type=simple
ExecStart=/bin/sh -c '/opt/ddns-cloudflare/ddns-cloudflare update
ExecStart=/bin/sh -c '/opt/ddns-cloudflare/ddns-cloudflare monitor
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

0 comments on commit 74dbdd3

Please sign in to comment.