Run Multiple Bash Scripts Using a Single systemd Service File

Configure a systemd service file to execute multiple bash scripts sequentially or concurrently, enabling automated tasks to run under a single service.

sudo nano /etc/systemd/system/custom-startup.service
[Unit]
Description=Run start.sh and sender.sh at boot
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/bin/bash -c '/usr/local/bin/start.sh & /usr/local/bin/sender.sh &'
WorkingDirectory=/usr/local/bin
Restart=always
User=root
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable custom-startup.service
sudo systemctl start custom-startup.service
sudo systemctl status custom-startup.service

Last updated