Skip to content

Instantly share code, notes, and snippets.

@contropist
Created February 26, 2019 05:35
Show Gist options
  • Save contropist/56b1a902cdc89eb3bc7a1515bb3715f0 to your computer and use it in GitHub Desktop.
Save contropist/56b1a902cdc89eb3bc7a1515bb3715f0 to your computer and use it in GitHub Desktop.
rclone 挂载 开机启动脚本

先把rclone的可执行文件复制到/usr/bin:

cp /root/rclone-v1.39-linux-amd64/rclone /usr/bin/rclone

新建一个rclone.service文件:

vi /usr/lib/systemd/system/rclone.service

写入:

[Unit]
Description = rclone
    
[Service]
User = root
ExecStart = /usr/bin/rclone mount gdrive: /www/wwwroot/nextcloud/data/user/files/googledrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
Restart = on-abort
    
[Install]
WantedBy = multi-user.target

重载daemon,让新的服务文件生效:

systemctl daemon-reload

现在就可以用systemctl来启动rclone了:

systemctl start rclone

设置开机启动:

systemctl enable rclone

停止、查看状态可以用:

systemctl stop rclone
systemctl status rclone

重启你的VPS,然后查看一下rclone的服务起来没,接着查看一下盘子挂上去没:

reboot
systemctl status rclone
df -h
@akira724
Copy link

akira724 commented Oct 9, 2019

怎么分多个配置文件,可以详细点吗

@GeorgeRudd
Copy link

怎么分多个配置文件,可以详细点吗

如果你想挂载多个网盘,那么将systemd配置文件的rclone.service改成rclone1.service即可,重启动什么的同样换成rclone1。

@dancer992
Copy link

大佬,有openwrt的脚本自启动教程吗?感谢!

@kitkw
Copy link

kitkw commented Dec 15, 2021

openwrt脚本+1
最近也被它困扰......................

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment