我将从系统日志中捕获并输出到另一个日志文件中的实时格式化urls列表中。
尾-F /var/log/system.log \ grep --行缓冲的"query=“/ sed -le "s/.*query=//”sed -le“s/\”/g“var -le "s/.$/ /”>> /tmp/urls.log“
如何像cronjob一样自动启动,但每次登录只运行一次。
原始日志文件如下所示:
query="www.yahoo.com.“
整个晚上都在为这事而挣扎!谢谢!
发布于 2011-11-12 16:52:22
使用LaunchAgent应该有效。使用以下内容创建一个.plist文件:
<?xml version="1.0" encoding="UTF-8"?>
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>label</key>
<string>name you want to give it</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/path/to/your/script.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>OnDemand</key>
<false/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>将此文件保存到~/Library/LaunchAgents。然后,您需要通过执行launchctl load -wF /path/to/launch.plist来加载启动程序。要确保正确加载,请检查它是否在这里,即launchctl list的输出。
有关更多信息,您可以查看Apple Developer 1和苹果开发者2
https://stackoverflow.com/questions/8105659
复制相似问题