Cobra Forum

Linux => New to Ubuntu => Topic started by: mahesh on Oct 06, 2023, 07:39 AM

Title: Can you run bash script on the startup as systemctl?
Post by: mahesh on Oct 06, 2023, 07:39 AM
Please excuse my ignorance, still learning linux. I have a script that I need to run at the start. Created .service and setup proper permissions but getting status 203 error:
Process: 8121 ExecStart=/etc/myFolder/bash startscript.sh (code=exited, status=203/EXEC)
Here is the service snippet:
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/myFolder/"bash startscript.sh"
Restart=on-failure
RestartSec=30
When running the script by itself it starts my command no problem. Any help would be greatly appreciated.

[Unit]
Description=start java app
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart="/bin/bash /etc/myFolder/startscript.sh"
Restart=on-failure
RestartSec=30

# Directory creation and permissions
####################################

# Run as admin:admin
User=admin
Group=admin
[Install]
WantedBy=multi-user.target

!whats inside the startscript bash .sh

java -jar javaApp.jar -c myConf.conf

Tried without /bin/bash with same error.