簡體   English   中英

Geektool和尾巴跟隨

[英]Geektool and tail follow

我有這個實時格式的URL列表,這些URL是從系統日志中捕獲並輸出到另一個日志文件的。

尾-F /var/log/system.log | grep --line-buffered“ query =” | sed -le“ s /.* query = //” | sed -le“ s / \\” // g“ | sed -le” s /.$/ /“ >> /tmp/urls.log

我如何像cronjob一樣自動啟動此操作,但每次登錄僅運行一次。

原始日志文件是這樣的:

x yy zzz query =“ www.yahoo.com。”。

整晚都在為此奮斗! 謝謝!

使用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 1Apple Developer 2。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM