Shell Script – Set a timer

February 2017




Issue


I would like set a timer in shell.

In fact, I would like to get a message to warn me by “echo” from my terminal at a certain hour of a day.
Have you an idea of the script I should use?

Solution


You must type the command directly into the terminal, as follows:

[tmpfs] now at $ 1 minutes <ENTER>
warning: commands will be executed using (in order) a) $ SHELL b) login shell c) /bin/sh
at> echo "Hello"> /dev/pts/2 <ENTER>
at> <EOT> <Ctrl+D>
job 22 at 2010-01-29 15:00
[tmpfs] $



You first enter the command followed by the date on which it is supposed to be done, and you validate by <ENTER>.

At the prompt (at>) you enter the command to be executed and where it must eventually be executed/displayed (in your case the terminal) and bodied by <ENTER>.

To finish and exit, <Ctrl+D> type (the <EOT> should not be typed, it is the result of the combination of CTRL + D).

Note


Thanks to jipicy for this tip on the forum.

Related


Published by aakai1056. Latest update on February 2, 2010 at 10:22 AM by aakai1056.
This document, titled "Shell Script – Set a timer," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).