Startup script with systemd in Linux
Try using "Type=forking" and use complete filename.
[Unit]
Description=Start aquarium server
[Service]
WorkingDirectory=/home/root/python/code/aquarium/
Type=forking
ExecStart=/bin/bash server.sh start
KillMode=process
[Install]
WantedBy=multi-user.target
if it not work, post output of this command:
# journalctl -u aquarium.service
SystemD service script will work on Systemctl start {service script} but not on reboot
To run the service just before your system reboots. You need to add this dependency to your service file.
[Unit]
Description=put cloudify in maintenance mode on shutdown
DefaultDependencies=no
After=final.target
[Service]
Type=oneshot
ExecStart=/bin/cfy maintenance-mode activate
TimeoutStartSec=0
[Install]
WantedBy=final.target
systemd doesn't run an application from bash script
Systemd will need to know how to run the script. Therefore either add:
#!/bin/bash
to the top line of the startup.sh script or change the ExecStart line in the systemd service file to:
ExecStart=/bin/bash -c /opt/somedir/startup.sh
Also, to ensure that the processes spawned remain persistent after being spawned, change:
Type=forking
launch terminal and execute script from systemd after reboot
You can create user systemd scripts that might help you out (https://wiki.archlinux.org/index.php/Systemd/User).
Here is a brief example of how you can start a script in a terminal from systemd (not on Ubuntu at the moment so not sure this will work with the paths) goes in your systemd user folder, probably /etc/systemd/user/:
[Unit]
Description=Start Script in terminal
[Service]
ExecStart=/usr/bin/xterm -hold -e /path/to/your/script.sh
[Install]
WantedBy=graphical.target
This will run for me on my system (Arch) with systemctl --user start servicename.service
The trick will be getting it to start once you have a full graphical environment up (with the script I have given if you ran systemctl --user enable servicename.service
it would almost certainly start before your window manager, since I am not in Ubuntu I can't test). This might help (last response): https://superuser.com/questions/759759/writing-a-service-that-depends-on-xorg . They are an Ubuntu user that got a systemd service to run a graphical program after login.
If you can figure the start timing out you can create the service file, create/enable it at the end of your first script and then disable/delete it at the end of your second.
Execute an interactive script in systemd-based initramfs
Ok, my bad. I tought the sd-vconsole
hook replaces the keyboard
hook, but it did not. So my keyboard drivers were missing. (That's why changing to tty2 manually did not work - should have given me a clue).
If somebody has problems, removing TTYVTDisallocate
makes debugging a bit easier.
Related Topics
How to Check If a Process Is in Hang State (Linux)
How to Check That Two Folders Are the Same in Linux
Android Studio Error After ./Studio.Sh
Setting Environment Variable Globally Without Restarting Ubuntu
Create Iptables Rule Per Process/Service
Check If File Exists on Remote Host with Ssh
Install Zsh Without Root Access
How to View Log Files in Linux and Apply Custom Filters While Viewing
How to Make Stdout and Stderr Output Be of Different Colors in Xterm or Konsole
What Is the Reason and How to Avoid the [Fin, Ack] , [Rst] and [Rst, Ack]
How to Download a File from the Internet to My Linux Server with Bash
Check If Environment Variable Is Already Set
Is It Better to Use Git Grep Than Plain Grep If We Want to Search in Versioned Source Code
How to Delete a User in Linux When the System Says Its Currently Used in a Process
How to Make Find and Printf Works in Bash Script