如何运行 bash 脚本并在 Conky 中显示任何输出?

lee*_*ker 6 script conky bash

我想在Conky 中运行的 Bash 脚本是一个循环,所以只需要运行一次。这是一个监控脚本,以防我的 VoIP 路由器出现故障。

${execi 3600 /home/justin/pingvoip}
Run Code Online (Sandbox Code Playgroud)

Conky 不想从上面的代码开始。

lee*_*ker 4

我通过将脚本输出到日志文件来解决这个问题,并且我已经 conky tail 日志文件。

对于任何想看脚本的人:

#!/bin/bash
rm /home/username/ping.log #deletes the log file when the script starts
downTime=0
lastAccessTime=$(date +"%s")
while [ true ]; do
if ! ping -c1 192.168.1.28 >& /dev/null; then
    downTime=$(( $(date +"%s") - $lastAccessTime ))
else
    downTime=0
    lastAccessTime=$(date +"%s")

fi

sleep 60

if [ $downTime -ge 60 ]; then
   notify-send -u normal "VoIP is down! Please Reboot." #displays a desktop notification
   mplayer -nolirc -really-quiet /home/username/chime.ogg #plays a sound
   echo "`date +%b%e,%l:%M%p` $1": "VoIP is down!" >>/home/username/ping.log #writes Date & text to the log file
fi


done
Run Code Online (Sandbox Code Playgroud)