如何使用 at 命令发送通知?

mem*_*und 6 command-line at-command

我有一个 bash 脚本,它每天使用crontab.

该脚本检查一个条件,如果为真,它应该at command在特定时间发出一个。

at 14:10 <notify-send hello>

问题是:如何notify-sendat命令添加特定命令?

Pil*_*ot6 11

echo "notify-send 'hello'" | at 14:10
Run Code Online (Sandbox Code Playgroud)

at 期待来自 STDIN 的命令。

如果要使/bin/sh警告静音,请按以下方式运行:

echo "notify-send 'hello'" | at 14:10 2>/dev/null
Run Code Online (Sandbox Code Playgroud)

  • 这是对 `echo` 和管道的无用使用。[此处字符串](http://tldp.org/LDP/abs/html/x17837.html) 会更合适:`at 14:10 &lt;&lt;&lt; "notify-send hello"`。 (2认同)