跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[分享创造] 写了个 rclone 同步脚本,分享给大家

发表于

脚本地址: https://github.com/ypq123456789/rclone_sync 借助 gpt 写了个 rclone 同步脚本,分享给大家,欢迎各位大佬测试使用、批评指正。代码小白是这样的,只能靠靠 gpt 了。

rclone_sync 简介

rclone_sync 是一个用于定时同步的脚本,利用 rclone 工具将文件从一个位置同步到另一个位置。

  • 如果直接将 rclone 同步的命令加入 crontab 并设置每小时同步,会导致出现上次同步还没结束又开启新一轮同步的问题。该脚本增加了是否有同步进程的检测,可以规避这一问题。
  • 本脚本会自动帮你安装 rclone 。
  • 本脚本支持自动更新。
  • 本脚本支持通过直链直接下载 rclone 二进制文件到相应位置,例如支持阿里云盘 openapi 的 rclone 版本
  • 本脚本支持通过直链直接下载配置文件到相应位置。
  • 由于本脚本在前台执行同步任务,建议在 screen 中执行

依赖

  • Unix-like 操作系统
  • rclone
  • curl

安装 curl

sudo apt install curl

rclone 配置

在使用此脚本之前,请确保你已经配置好 rclone 。你可以通过以下命令检查 rclone 配置:

rclone config

如果 rclone 未配置,请参考rclone 官方文档进行安装和配置。

脚本执行

一键脚本

sudo curl -o /root/rclone_sync.sh -f https://raw.githubusercontent.com/ypq123456789/rclone_sync/main/rclone_sync.sh && chmod +x /root/rclone_sync.sh && cd /root && ./rclone_sync.sh

下载/更新脚本

sudo curl -o /root/rclone_sync.sh -f https://raw.githubusercontent.com/ypq123456789/rclone_sync/main/rclone_sync.sh

手动运行脚本

sudo cd /root && ./rclone_sync.sh

在 screen 中执行

安装 screen

sudo apt-get install screen

创建并进入 rclone 窗口

screen -S rclone

在 screen 中执行脚本

sudo curl -o /root/rclone_sync.sh -f https://raw.githubusercontent.com/ypq123456789/rclone_sync/main/rclone_sync.sh && chmod +x /root/rclone_sync.sh && cd /root && ./rclone_sync.sh

脱离窗口

ctrl+A ,然后按 D

进入窗口

screen -r rclone

同步

本脚本默认为您设置每小时切换到 /root 目录并执行 rclone_sync.sh 脚本,命令如下

sudo echo -e "0 * * * * cd /root && ./rclone_sync.sh" | crontab -

如果你想要修改,使用以下命令自行编辑

sudo crontab -e

查看日志

查看 rclone 日志(建议在 screen 中执行脚本,回到主界面查看 rclone 日志)

watch -n 1 "tail -n 10 /root/rclone.log"

查看 rclone_sync 日志

tail -n 30 /root/rclone_sync.log

贡献

欢迎提交问题( Issues )和合并请求( Pull Requests )以改进此脚本。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.