0

我想为我的 Raspberry Pi 2 编写一个在启动时运行并永久监视特定目录中的更改的守护程序脚本。如果有更改,它应该将更改的文件复制到 Windows 计算机上的目录(可能通过 SSH)。

我发现监视文件的 Python 的 Gamin 库可以提供帮助(https://people.gnome.org/~veillard/gamin/python.html),但我不确定 bash 脚本是否更适合工作,尤其是文件传输。不幸的是,我刚刚开始深入研究 Unix 和 Python,并且可以使用一些有用的建议来解决这个问题的最佳方法。

4

1 回答 1

1

您可以签出此手表脚本并将睡眠时间设置为您想要检查的任何时间间隔

https://gist.github.com/mikesmullin/6401258

将其添加到 systemd 或 init.d 并使用它通过 scp 进行复制。

https://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd

https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian

代替 scp 您可以将目录设为 git 存储库,并让脚本每次都提交并推送更改。

git add -u
git commit -m "<your standard commit message>"
git push

点击此链接了解有关如何在 Windows 上设置 git 服务器的更多信息

https://github.com/msysgit/msysgit/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-CopSSH

于 2015-05-22T14:46:48.860 回答