0

hey i'm trying to get my system to run a terminal command on startup everything i've found says to launch a script using a systemd service but nothing even begins to go into what i'd even type in that script and I'm not a programmer. the command i want to run is rclone sync / b2-004:alice-ubtntu-2295 --copy-links

I use Ubuntu 22.04

2
  • What you need to do is to write a systemd Service Unit which executes the command. This is an extremely common task and there thousands of webpages explaining that. Just search for something like "create systemd Service unit".
    – noisefloor
    Commented Sep 9, 2023 at 19:06
  • Trust the documentation on the local system over what some Internet Rando says. Internet Rando has no knowledge of your exact circumstances. Build your knowledge. Read man systemd systemd.service Take advice from linuxhandbook.com/create-systemd-services
    – waltinator
    Commented Sep 9, 2023 at 19:30

1 Answer 1

4

Here is a simple means to get it done, but please look at man systemd systemd.service to learn a bit more:

  1. Create the systemd unit file with your nano text editor:

    sudo nano /etc/systemd/system/my-clone-sync.service
    
  2. Add the following lines:

    [Unit]
    Description=Clone Sync Service
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/clone sync / b2-004:alice-ubtntu-2295 --copy-links
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    

    Make sure to provide the full path to the clone command if it's not in the system's default PATH.

  3. Save and exit:

    Save the changes to the systemd unit file and exit the text editor.

    • ctrl + X
    • shift + Y
    • Return key
  4. Enable and start the service:

    After modifying the unit file, enable and start the service as previously described:

    sudo systemctl enable my-clone-sync.service
    sudo systemctl start my-clone-sync.service
    
  5. Check the service status:

    To verify that the service is running and monitor its status:

    sudo systemctl status my-clone-sync.service
    

You must log in to answer this question.

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