Mac 共享网盘定时批量连接

tags
Tool
date

问题

Mac 共享网盘长期在神秘力量的控制下自动断开连接,导致访问不顺畅(产生 Sketch 组件库调用障碍等问题)

方案

批量连接

通过 Apple Script 实现
notion image
新建 1 个 Apple Script 文件
tell application "Finder"
	mount volume "smb://fs27.xxxx.internal/fs27工作备份2020" as user name "xxxx"
end tell
将上述两个引号内的字符分别替换为`共享网盘地址`、`自己的工号`即可
添加多条连接命令
tell application "Finder"
	mount volume "smb://fs27.xxxx.internal/fs27工作备份2020" as user name "xxxxx"
	mount volume "smb://fs29.xxxx.internal/CC直播" as user name "xxxx"
end tell
我根据自己需求写好的脚本如下
notion image
可以手动执行此脚本实现批量连接

定时连接

通过 `crontab` 实现
打开终端
notion image
输入命令
crontab -e
notion image
键入 `i` 进入编辑状态
notion image
输入
00 10 * * * osascript /Users/cc/Documents/江子龙jiangzilong/minpg/connectToSMB.scpt
含义:在每天 10:00 执行 1 次 connectToSMB.scpt(前面创建好的脚本文件)
多个时间点:
notion image
编辑完毕后键入 `Esc` 退出编辑状态
notion image
键入`:wq` 回车保存
notion image
完成配置
notion image
注意:连接网盘需要账号密码,需要勾选密码保存到钥匙串中

© jiangzilong 2024