0

I have my "c" application which uses a lot of printf to display the necessary information. Application has started automatically at boot time (using init.d or systemd). How I can access to it's console? I am not interesting in all data since application was started. I want to view current data... Should I use tmux?

1 Answer 1

0

Thanks topic. I solved for Ubuntu 24. This is my step-by-step explanation.

  1. Preparation

    sudo apt install htop nano tmux -y
    
  2. Make service to call tmux and start the application (in this example htop but it can be any user application).

    sudo nano /etc/systemd/system/myservice.service
    
    [Unit]
    Description=my tmux service
    After=multi-user.target # https://unix.stackexchange.com/questions/404667/systemd-service-what-is-multi-user-target
    
    [Service]
    User=q
    Group=q
    ExecStart=bash -c "tmux new-session -s q -d 'htop'"
    Type=forking
    
    [Install]
    WantedBy=multi-user.target
    
  3. Ask systemd to start our service at boot.

    sudo systemctl enable myservice.service
    
  4. Service will start after reboot. We should do reboot or start immediately.

    sudo systemctl start myservice
    
  5. You can connect long way

    ssh [email protected]
    tmux attach
    

    Or you can connect short way. Thanks topic

    ssh [email protected] -t tmux a
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .