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?

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
  • I am testing your command I see this error warning: commands will be executed using /bin/sh, what does it mean? – George Udosen Jun 12 '17 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 '17 at 12:39
  • 1
    @George I added how to silence the warning. – Pilot6 Jun 12 '17 at 12:44
  • ok but I prefer to see it in case I did something dumb :) – George Udosen Jun 12 '17 at 12:45
  • 1
    This is useless use of echo and pipe. A Here String would be more appropriate: at 14:10 <<< "notify-send hello". – Ruslan Jun 12 '17 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.