Lsyncd选项问题
2012-6-1 4:55:53
收藏:0
阅读:181
评论:3
我正在尝试使用名为 lsyncd 的软件,它使用一个用 Lua 编写的配置文件来存储配置选项。
settings = {
logfile = "/logs/log.log",
pidfile = "/var/run/lsyncd.pid",
statusFile="/var/log/lsyncd.stat",
statusIntervall=5,
delay = 1
}
sync {
default.rsync,
source = "/source/folder",
target = "/destination/folder",
excludeFrom="/etc/exclude",
}
手册讲述了在动作上运行命令的能力,甚至给出了一个例子
fgroup = "staff"
-----
-- script for all changes.
--
command =
-- checks if the group is the one enforced and sets them if not
'[[
perm=`stat -c %A ^sourcePathname`
if test `stat -c %G ^sourcePathname` != ]]..fgroup..'[[; then
/bin/chgrp ]]..fgroup..'[[ ^sourcePathname || /bin/true;
fi
]] ..
-- checks if the group permissions are rw and sets them
'[[
if test `expr match $perm "....rw"` = 0; then
/bin/chmod g+rw ^sourcePathname || /bin/true;
fi
]] ..
-- and forces the executable bit for directories.
'[[
if test -d ^sourcePathname; then
if test `expr match $perm "......x"` -eq 0; then
/bin/chmod g+x ^^sourcePathname || /bin/true;
fi
fi
]]
-- on startup recursively sets all group ownerships
-- all group permissions are set to 'rw'
-- and to executable flag for directories
--
-- the hash in the first line is important, otherwise due to the starting
-- slash, Lsyncd would think it is a call to the binary /bin/chgrp only
-- and would optimize the shell call away.
--
startup =
'[[#
/bin/chgrp -R ]]..fgroup..'[[ ^source || /bin/true &&
/bin/chmod -R g+rw ^source || /bin/true &&
/usr/bin/find ^source -type d | xargs chmod g+x
]]
gforce = {
maxProcesses = 99,
delay = 1,
onStartup = startup,
onAttrib = command,
onCreate = command,
onModify = command,
-- does nothing on moves, they won't change permissions
onMove = true,
}
sync{gforce, source="/path/to/share"}
但我只想在 onCreate、onModify、onMove 上执行一个简单的本地命令
/path/to/script.sh args
我知道这可能很简单,但我无法弄清楚。
点赞
用户2538262
请尝试使用 python 脚本软件 Watcher,并将 jobs.yml 配置为示例。
......
事件:['create','modify','move']
......
命令:/path/to/script.sh args
2013-07-02 10:02:23
用户693291
尝试像这样做:
my_cmds =
[[
/path/to/script.sh args
]]
monitor =
{
delay = 1,
onAttrib = my_cmds,
onCreate = my_cmds,
onModify = my_cmds,
onMove = my_cmds,
}
sync
{
monitor,
source = "/source/folder",
target = "/destination/folder",
}
(翻译完毕)
2014-08-06 17:46:51
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
命令似乎是字符串。所以我会尝试:
... onStartup = "/path/to/script.sh args", onAttrib = [[/path/to/script.sh args]], -- '',""和[[ ]]都是字符串定界符 ....