Search results

/postroll

Magento Cron via systemd timers | bitExpert

blog.bitexpert.de

Debian and Ubuntu are no longer shipping cron by default, and instead recommending setting up systemd timers. Stephan details how this is done, which requires both a systemd service file, and a systemd timer file.

The service file looks like this:

### Goes into /etc/systemd/system as a file with a .service extension
[Unit]
Description=Description of the service here
Wants=service-name.timer

[Service]
Type=oneshot
ExecStart=/path/to/executable/to/run/here
User=user-to-run-as
Group=group-to-run-as

[Install]
WantedBy=multi-user.target

You then create a timer, which is a systemd service defining a Timer section with an interval specified:

### Goes into /etc/systemd/system as a file with a .timer extension

[Unit]
Description=Executes every minute
Requires=service-name.service

[Timer]
Unit=service-name.service
OnCalendar=minutely

[Install]
WatnedBy=multi-user.target

The OnCalendar property can use "natural language" shortcuts like "minutely" or "hourly", or you can define date/time-based interval such as *-*-* *:*:00.

Once done, you need to start the service and enable the timer (usually as root):

systemctl start service-name.service
systemctl enable service-name.timer

and trigger it manually any time using:

systemctl start service-name.service

Search tips

  • Use #{some tag} or tag:{some tag} to filter by tag; using this more than once will find results that match all tags.
  • Use year:{year} to filter by year. If you use this multiple times, the last one wins.
  • Use begin:{year-month-day} to restrict to results beginning on that day. Last one wins.
  • Use end:{year-month-day} to restrict to results ending on that day. Last one wins.