8

I have a bash script that runs periodically once a day using crontab.

The script checks a condition, and if true, it should issue an at command at a specific time.

at 14:10 <notify-send hello>

The question is: how can I add a specific command like notify-send to the at command?

2 Answers 2

13
echo "notify-send 'hello'" | at 14:10

at is expecting a command from STDIN.

If you want to silence the /bin/sh warning, run it this way:

echo "notify-send 'hello'" | at 14:10 2>/dev/null
10
  • I am testing your command I see this error warning: commands will be executed using /bin/sh, what does it mean? Jun 12, 2017 at 12:37
  • 1
    This means literally what is said. /bin/sh will be used as a shell for the command. It is OK if you are worried.
    – Pilot6
    Jun 12, 2017 at 12:39
  • 1
    @George I added how to silence the warning.
    – Pilot6
    Jun 12, 2017 at 12:44
  • ok but I prefer to see it in case I did something dumb :) Jun 12, 2017 at 12:45
  • 2
    This is useless use of echo and pipe. A Here String would be more appropriate: at 14:10 <<< "notify-send hello".
    – Ruslan
    Jun 12, 2017 at 12:53
2

As I was searching for a fast way to remind myself using dunstify/notify-send I want to promote @Ruslan 's comment, because it involves less typing (which is essential when you want to "just set a timer")

at now + 3minutes <<< "notify-send -t 0 'tee is ready'"

... or with less whitespace/characters:

at now+3min<<<'notify-send -t 0 tee isready'
  • -t 0 don't timeout the notification and keep it open

and just for information: as an improvement to atq or at -l listing I use an alias that also prints the executed command, not just time/queue/user:

alias ,atl='for j in $(atq | sort -k6,6 -k3,3M -k4,4 -k5,5 |cut -f 1); do atq |grep -P "^$j\t" ;at -c "$j" | tail -n 2; done'

(as mentioned here in serverfault)

* tested with Manjaro21/Debian10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .