How to run a systemd script at boot automatically
From KoanSoftware Wiki
How to run a systemd script at boot automatically using Linux
If you need to run a script at boot automatically using Linux with systemd this is the easiest solution.
- Create a script file calling your application
# vi /home/root/flutter-launcher.sh
#!/bin/sh flutter-auto --b=/usr/share/flutter/gallery/3.3.10/release/ --f
- Modify the executable flag
# chmod +x /home/root/flutter-launcher.sh
- Create the service
# vi /etc/systemd/system/flutterstart.service
[Unit] Description=Flutter starter [Service] ExecStart=/home/root/flutter-launcher.sh [Install] WantedBy=multi-user.target
Now, take a few more steps to enable and use the .service file:
- Start it
# sudo systemctl start flutterstart
- Enable it to run at boot
# sudo systemctl enable flutterstart
- Test it
# systemctl status flutterstart * flutter-start.service - Flutter starter Loaded: loaded (/etc/systemd/system/flutterstart.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2023-03-06 17:11:38 UTC; 3min 29s ago Main PID: 245 (flutterstart) CGroup: /system.slice/flutterstart.service |- 245 /bin/sh /home/root/flutter-starter.sh `- 272 flutter-auto --b=/usr/share/flutter/gallery/3.3.10/release/ --f