Skip to content
MultiloginHelp Center

How to configure the agent for Linux autolaunch

On Ubuntu, you can make the Multilogin agent start automatically in headless mode by creating two systemd services: one for Xvfb and one for the Multilogin agent. Xvfb provides the virtual display the agent needs, while systemd starts both services automatically when the server boots.

Keep in mind that the article is written for Ubuntu. The other distributions are not officially supported.

Step 1: set up Xvfb

Xvfb (X Virtual Framebuffer) is a display server that lets graphical applications run in environments without a physical display by creating a virtual screen in memory. It will be needed for the agent to work as intended.

  1. Open Terminal
  2. Create the Xvfb service file by typing the following command:
    sudo nano /etc/systemd/system/xvfb.service
  3. Add the content to the service file (and make sure to replace YOUR_USERNAME with your username in Linux OS):
    [Unit]
    Description=MLX XVFB
    After=network.target
    
    [Service]
    Type=simple
    User=YOUR_USERNAME
    ExecStart=/usr/bin/Xvfb :99 -screen 0 1920x1080x24
    Restart=always
    
    [Install]
    WantedBy=multi-user.target

    In ExecStart we configure the resolution, the number of displays, and the directory for Xvfb.

  4. Press CTRL+X, then Y and Enter to close and save

Step 2: set up agent for auto-launch

  1. Open Terminal
  2. Create the Xvfb service file by typing the following command:
    sudo nano /etc/systemd/system/mlx.service
  3. Add the content to the service file (and make sure to replace YOUR_USERNAME with your username in Linux OS):
    [Unit]
    Description=MLX Agent
    After=xvfb.service
    Requires=xvfb.service
    
    [Service]
    Type=simple
    User=YOUR_USERNAME
    Environment=HOME=/home/YOUR_USERNAME
    Environment=DISPLAY=:99
    ExecStartPre=-/usr/bin/pkill -9 -f mlx
    ExecStartPre=-/bin/rm -f /home/YOUR_USERNAME/mlx/agent.lock /home/YOUR_USERNAME/mlx/profiles.lock /home/YOUR_USERNAME/mlx/launcher.lock
    ExecStart=/usr/bin/mlx
    Restart=on-failure
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target

    Let's understand what this service does:

    In [Unit], we wait for the Xvfbservice so we don't risk getting display errors.
    In [Service], we set the user, home variable and display variable. The display variable is set in the agent service and not Xvfb, otherwise the agent would not be able to use it.
    Then, with ExecStartPre we kill any remaining agent processes and delete the .lock files, this is useful in case the service restarts.
    ExectStart is the path for the agent binary in Linux.

  4. Press CTRL+X, then Y and Enter to close and save

Step 3: enable and load the services

  1. Reload daemon (a background service, which loads up the other services):
    sudo systemctl daemon-reload
  2. Enable both Xvfb and Multilogin agent as services:
    sudo systemctl enable xvfb.service mlx.service
  3. Use systemctl (a utility tool used for managing system services) for starting the services:
    sudo systemctl start xvfb.service
    sudo systemctl start mlx.service
    Congratulations! Now the agent and Xvfb will be launched during the OS startup. 

How to use systemctl for managing services

Use systemctl utility for checking the service status. You can use them for getting logs and troubleshooting.

Check service status

Let’s get the service status with: 

sudo systemctl status xvfb.service

You will see the actions of the Xvfb service. You can also change xvfb.service to the name of your service if it’s different.

Get logs

Get the service logs with journalctl service:

journalctl -u mlx.service

You can also limit it by line amount. With this command you can limit the lines up to 100:

journalctl -u mlx.service -n 100

You can also limit service logs for a time period. Here is the command for limiting the last 30 minutes of logs:

journalctl -u mlx.service --since "30 minutes ago"

-f is used for displaying logs in real time:

journalctl -u mlx.service -f

Stay in the loop

Catch the latest updates, exchange advice, explore practical use cases.

Get product updatesTelegram channelAsk other usersTelegram chatExplore use casesDiscord community