Skip to content

Instantly share code, notes, and snippets.

@dan-rally
Last active September 14, 2020 16:55
Show Gist options
  • Select an option

  • Save dan-rally/2cdfbbb019648733f5f2b6223f9fd481 to your computer and use it in GitHub Desktop.

Select an option

Save dan-rally/2cdfbbb019648733f5f2b6223f9fd481 to your computer and use it in GitHub Desktop.
Craft queue systemd timers

Using systemd timers for Craft Queue

systemd can run specific tasks at specific times or events. You need to create 2 unit files:

  1. Create a service file:
$ sudo nano /etc/systemd/system/craft-queue.service

And add the service attached to this gist, adapting the ExecStart path to match the one on your server.

  1. Create a timer file:
$ sudo nano /etc/systemd/system/craft-queue.timer

Add the timer file attached to this gist, adapting the OnCalendar to suit (see documentation).

  1. Reload systemd:
$ systemctl daemon-reload
  1. Enable the timer:
$ systemctl enable craft-queue.timer
  1. Start the timer:
$ systemctl start craft-queue.timer

Gist adapted from blog at https://kenfavors.com/code/nextcloud-crontab-cronjob-settings/.

[Unit]
Description=Run Craft Queue every 10 seconds
[Timer]
OnBootSec=1min
OnCalendar=*:*:0/10
AccuracySec=1s
[Install]
WantedBy=timers.target
[Unit]
Description=Craft Queue
[Service]
Type=oneshot
User=www-user
ExecStart=/usr/bin/php -f /var/www/www.dengro.com/craft queue/run
[Install]
WantedBy=basic.target
[Unit]
Description=Run Craft Queue every minute
[Timer]
OnBootSec=1min
OnCalendar=*:0/1
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment