PortGate

Blueprints · Laravel & PHP

Production 15 min · systemd

Laravel scheduler timer

Stages a systemd timer that runs schedule:run as the app user. It does not enable the timer.

Live config

Baked-in protections

Step 1 · ini

Service unit

/root/portgate-blueprints/laravel-schedule.service

Copy both units into /etc/systemd/system and enable the timer after php and the app path exist.

[Service]
Type=oneshot
User=www-data
WorkingDirectory=/var/www/app
ExecStart=/usr/bin/php artisan schedule:run

Step 2 · ini

Timer unit

/root/portgate-blueprints/laravel-schedule.timer

Starts one minute after boot and then every minute.

[Timer]
OnBootSec=1min
OnUnitActiveSec=1min
Unit=laravel-schedule.service

[Install]
WantedBy=timers.target

Step 3 · bash

Read-only check

/root/portgate-blueprints/schedule-check.sh

Prints status. It does not change the service.

#!/bin/sh
set -eu
systemctl list-timers --all | grep laravel || echo "The Laravel timer is not installed."