-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace cron jobs with systemd timers on infra systems #590
Comments
Syntax btw (for above rsync script): # tail -n +1 /etc/systemd/system/rsyncmirror.*
==> /etc/systemd/system/rsyncmirror.service <==
[Unit]
Description=runs a rsync mirror against nodejs main server
[Service]
Type=oneshot
ExecStart=/usr/bin/rsync -e "ssh" -a -q --exclude "doc" --exclude "docs" --exclude "metrics" --exclude "tools" --exclude ".*" --exclude "rsync-old-nodejs.org.sh" --exclude "www" --delete root@host:/home/dist/ /home/dist/
==> /etc/systemd/system/rsyncmirror.timer <==
[Unit]
Description=run the rsync mirror job every 15 minutes
[Timer]
OnCalendar=*:0/15 |
Makes sense to me if it means we can reuse scripts. |
I guess the same applies for a checked in cron job (but os-specific things could be different). I just really liked the tools to control timed scripts; getting full log history and confirmation that it ran successfully. It takes a bit more polish to get cron jobs to that shape. |
Syntax as listed by @jbergstroem above does not make the timer active on startup, so a Updated syntax for reference: # tail -n +1 /etc/systemd/system/rsyncmirror.*
==> /etc/systemd/system/rsyncmirror.service <==
[Unit]
Description=runs a rsync mirror against nodejs main server
[Service]
Type=oneshot
ExecStart=/usr/bin/rsync -e "ssh" -a -q --exclude "www" --exclude "doc" --exclude "metrics" --exclude "tools" --exclude ".*" --exclude "rsync-old-nodejs.org.sh" --delete root@direct.nodejs.org:/home/dist/ /home/dist/
ExecStartPost=/usr/bin/rsync -e "ssh" -a -q --delete root@direct.nodejs.org:/home/www/ /home/www/
==> /etc/systemd/system/rsyncmirror.timer <==
[Unit]
Description=run the rsync mirror job every 15 minutes
[Timer]
OnBootSec=1min
OnUnitActiveSec=15min
[Install]
WantedBy=timers.target Then to enable the timer: # systemctl enable rsyncmirror.timer
Created symlink from /etc/systemd/system/timers.target.wants/rsyncmirror.timer to /etc/systemd/system/rsyncmirror.timer. |
Closing as stale, but if anyone wants to take this up feel free to reopen. |
Systems running systemd can use the built in timers functionality which is intended to replace cron. The benefits (for us) using these are:
I'd like to move things we do in cron today, such as rsync:ing backups, benchmark and so on to this. Thoughts?
The text was updated successfully, but these errors were encountered: