How to automatically execute a script at login?

I want to run this command at login or startup.

rclone mount gdrive: /media/gdrive  --vfs-cache-mode writes --config=/home/hemanth/.config/rclone/rclone.conf --allow-non-empty

I tried to create a system service but it was executed as a superuser which cut my access to files.

# /etc/systemd/system/rclone.service
Description=Google Drive (rclone)


rclone mount gdrive: /media/gdrive  --vfs-cache-mode writes --config=/home/hemanth/.config/rclone/rclone.conf --allow-non-empty

The command I’m running is to mount my Gdrive at startup using rclone

I’m running fedora 34 gnome. Now all I wanted to do is to run this command every time I log in. Help me to execute this.

I never uses rclone, but did you know that we can add online account on Gnome setting (Google account) and it will also give us access to Google drive directly from Nautilus (default Gnome file explorer)?

1 Like

If you want to use systemd, it would need to be a user service. systemd/User - ArchWiki

1 Like

No it’s not a reliable option. It’s presently not working for me.

Creating from systemd is getting hectic as it is mounting it with root privillages.

Presently I did a workaround by creating a desktop entry with

rclone mount gdrive: /media/gdrive  --vfs-cache-mode writes --config=/home/hemanth/.config/rclone/rclone.conf --allow-non-empty

through Menulibre and kept it in the startup applications and it’s working very good.

And now I’m back to my KDE setup. I couldn’t handle the gnome for long.
Starting a script with KDE is pretty straightforward.

So without looking at if the script and *.service are correct and work I think what you want to know is how to actually activate the service.

systemctl daemon-reload

should check for changes in /etc/systemd/system

systemctl enable rclone.service

should activate your rclone service and mount it whenever your system boots to (which looks correct, seeing that you are mounting a resource that requires network-drivers to be active)

It should also tell you that it created a symlink to somewhere (I can never remember where)

Link to my source - in case you need more info about the usage of systemd:

1 Like