A Laravel queue worker started by hand in a terminal dies the moment the SSH session closes, the server reboots, or the process crashes. On an Ubuntu EC2 server running Redis queues, that means jobs sit unprocessed until someone notices. A systemd service fixes all three problems: it starts the worker at boot, restarts it when it fails, and gives you one place to check its logs.
Why systemd instead of a terminal session
Tools like nohup or a detached tmux session keep a worker alive, but they do not restart it after a crash and they do not survive a reboot. systemd is already running on every Ubuntu server as process 1, so there is nothing extra to install. A service unit declares what to run, which user runs it, and what to do when it exits. That is the whole job, and it is exactly what a queue worker needs.
Write the service unit
Create the unit file at /etc/systemd/system/laravel-worker.service. Replace /var/www/app with your application path and www-data with the user that owns the code:
[Unit]
Description=Laravel Queue Worker
After=network.target redis-server.service
Wants=redis-server.service
[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/app
ExecStart=/usr/bin/php artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
The flags matter. --sleep=3 pauses three seconds between polls when the queue is empty, so an idle worker does not hammer Redis. --tries=3 caps retries before a job moves to the failed jobs table. --max-time=3600 makes the worker exit after one hour, and systemd restarts it, which keeps memory usage from growing without bound over days. Restart=always is what brings the worker back after a crash or an out of memory kill.
Enable and start the service
Reload systemd so it sees the new unit, then enable it so it starts at boot and start it now:
sudo systemctl daemon-reload
sudo systemctl enable --now laravel-worker
sudo systemctl status laravel-worker
The status output should show active (running). If it shows a failure, check the logs before changing anything:
sudo journalctl -u laravel-worker -f
Most first-time failures are permission problems. The worker runs as www-data, so that user needs read access to the code and write access to storage/logs and bootstrap/cache. Fix ownership with sudo chown -R www-data:www-data /var/www/app/storage /var/www/app/bootstrap/cache and restart the service.
Restart workers on every deploy
A running worker loads your code into memory once and keeps it. Deploying new code does not change what the worker is executing. The fix is one command in your deploy script, after the new code is in place:
php artisan queue:restart
This signals all workers to exit gracefully after finishing their current job. systemd restarts them immediately with the new code. Add it to every deploy, or a bug you fixed will keep running in production until the worker happens to restart. If you monitor queues, pair this with the alerting setup in Laravel Horizon: Queue Monitoring That Actually Pages You so a worker that fails to come back gets noticed fast.
Running more than one worker
One worker processes one job at a time. When the queue backs up, add a second service instead of overloading the first. Copy the unit to laravel-worker-2.service and start it the same way. A cleaner approach for several workers is a template unit, laravel-worker@.service, where the instance name becomes part of the service:
sudo systemctl enable --now laravel-worker@1
sudo systemctl enable --now laravel-worker@2
Scale workers to the work, not to the server size. Each worker holds a database connection and a Redis connection, so watch connection counts before adding many. Two or three workers handle most small applications. If one queue is slow and another is urgent, run separate workers per queue with --queue=high,default so slow jobs never block fast ones.
Takeaway
A systemd service turns a fragile terminal process into a managed part of the server: it starts at boot, restarts on failure, and logs in one place. Write the unit once, enable it, and add queue:restart to your deploy script. From then on the worker is infrastructure, not something you have to remember to start.