Unable to run systemctl services at startup


  • 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.



  • Dear @Riccardo Benedetti,

    Enter as a root in the terminal and type below command to see the error log.
    $ su
    $ journalctl -u test_service.service

    Try to change the directory and script permission to read/write.
    $ chown root:root
    $ chmod 755


  • @Kothandaraman Kannadasan Thank you for your reply, all the permissions are fine, i tested also other services like the official docker's one. Same result. Service started if launched with

    systemctl start

    but when enabled they don't start at boot.


  • I also add that there are a lot of failed services on a freshly fladhed board (tried 3 times with FHD and 4K images, same result). It seems that the image you are providing has some issues.

    $ systemctl --failed
      UNIT                    LOAD   ACTIVE SUB    DESCRIPTION            
    ● chg-policy.service      loaded failed failed Charger Policy Service 
    ● diag-reboot-app.service loaded failed failed diagrebootapp service  
    ● fs-scrub-daemon.service loaded failed failed fs-scrub-daemon Service
    ● init_post_boot.service  loaded failed failed QTI Post Boot Service  
    ● init_sys_mss.service    loaded failed failed Modem Init Service     
    ● mirror_copy.service     loaded failed failed Mirror Copy Service    
    ● qti_pppd.service        loaded failed failed qti_ppp service        
    ● qtid.service            loaded failed failed qti service            
    ● thermal-engine.service  loaded failed failed Thermal Engine Service 
    ● wlan_daemon.service     loaded failed failed Wlan Service           
    
    

  • Hi @Kothandaraman Kannadasan any news on this?

    Best regards


Please login to reply this topic!