I’m facing an issue with a systemd service I created on an I-PI SMARC RB5. The service is supposed to execute a simple Bash script at boot, but it does not start automatically. I tested variuos services with the same result, any of them like the docker official one, wont start during boot as well; this is just a sample one. Here are the details:
Script (/home/username/test.sh):
#!/bin/bash
echo "Script started at $(date)" >> /home/username/test_service.log
Service File (/etc/systemd/system/test_service.service):
[Unit]
Description=Test Service
After=network.target
[Service]
ExecStart=/home/username/test.sh
Restart=no
Type=oneshot
SyslogIdentifier=test_service
User=root
[Install]
WantedBy=multi-user.target
Current Status:
1. The script works correctly when executed manually:
sh /home/username/test.sh
It writes the expected output to `/home/username/test_service.log`.
2. The service starts correctly when triggered manually and I can see a line added to the log:
sudo systemctl start test_service.service
3. The service is enabled for startup:
sudo systemctl is-enabled test_service.service
Output:
enabled
4. No logs are recorded for this service after boot:
sudo journalctl -u test_service.service -b
Output:
-- No entries --
5. No errors and logs in journalctl
username@hostname:~$ sudo journalctl -b | grep test_service
Nov 22 09:38:28 hostname sudo[2264]: username : TTY=pts/0 ; PWD=/home/username ; USER=root ; COMMAND=/usr/bin/journalctl -u test_service.service -b
username@hostname:~$ sudo systemctl start test_service.service
username@hostname:~$ sudo journalctl -b | grep test_service
Nov 22 09:38:28 hostname sudo[2264]: username : TTY=pts/0 ; PWD=/home/username ; USER=root ; COMMAND=/usr/bin/journalctl -u test_service.service -b
Nov 22 09:39:19 hostname sudo[2271]: username : TTY=pts/0 ; PWD=/home/username ; USER=root ; COMMAND=/usr/bin/systemctl start test_service.service
Nov 22 09:39:19 hostname systemd[1]: test_service.service:
Succeeded.
6. systemctl status test_service.service:
systemctl status test_service.service
test_service.service - Test Service
Loaded: loaded (/etc/systemd/system/test_service.service; enabled; vendor preset: enabled)
Active: inactive (dead)
---
What I've Tried:
- Verified the script is executable and has the correct permissions (`chmod +x /home/username/test.sh`).
- Reloaded the systemd configuration with `sudo systemctl daemon-reload`.
- Re-enabled the service with `sudo systemctl enable test_service.service`.
- Checked for errors using `sudo systemd-analyze verify /etc/systemd/system/test_service.service`—no errors were reported.
Questions:
1. Why any service that i add doesn’t start automatically at boot, even though it is enabled and works fine manually?
Any help or insights would be greatly appreciated.