Can you run bash script on the startup as systemctl?
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.
Re: Can you run bash script on the startup as systemctl?
Did you set the script to be executable?
Re: Can you run bash script on the startup as systemctl?
You need to specify the full path to the conf file in your script as well
Re: Can you run bash script on the startup as systemctl?
There's a discrepancy between the two snippets you posted. Is it
or
Quote:
ExecStart="/bin/bash /etc/myFolder/startscript.sh"
?
If it's the former, then it's kind of obvious: 203 is 'can't execute this' either because the file isn't there or it's not executable or it's a script without a shebang-line (a line telling the system what interpreter to use for a script, like '#!/bin/bash') and there's no file named 'bash startscript.sh' (with a space in the file name) in /etc/myfolder/. If it's the latter, I'd try without the quotes or I'd make the script executable (sudo chmod a+x /etc/myfolder/startscript.sh), put in a shebang line as the first line of the script and change the ExecStart-line to 'ExecStart=/etc/myfolder/startscript.sh'.
Beyond that: the environment at the time services are run and in a shell after login are rather different. You might need to set a whole lot of environment variables that the Java-runtime expects which aren't set this early in the boot process.
Holger