TMUX in Systemctl - LeandroTheDev/arch_linux GitHub Wiki
- Create a script to run your desired program:
/home/test/start-program.sh
#!/bin/sh
./my_program
- Create a start-systemctl.sh file to be called by the systemd
-
The while infinite is still necessary, because if the script ends the TMUX session will also be closed
#!/bin/sh
tmux new-session -d -s ttyname "bash -c './start-program.sh'"
sleep 3600
while true
do
...
sleep 3600
done
- Create the service for systemd: sudo vim /etc/systemd/system/myprogram.service
[Unit]
Description=Starts the program
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash /home/test/start-systemctl.sh
WorkingDirectory=/home/test/
User=userprogram
[Install]
WantedBy=multi-user.target