Page 1 of 1

How to set a timer? [Solved]

Posted: Mon Feb 22, 2021 12:05 am
by AbhijitKumarSingh
I need to set a timer using the terminal, is there a way?

Re: How to set a timer?

Posted: Mon Feb 22, 2021 1:55 am
by 1000
Which timer?

Re: How to set a timer?

Posted: Mon Feb 22, 2021 2:10 am
by freshminted
Try the "at" command? You may have to install it first.

Re: How to set a timer?

Posted: Mon Feb 22, 2021 6:11 am
by AndyMH
Do you mean a cron job?

Re: How to set a timer?

Posted: Mon Feb 22, 2021 9:07 am
by AbhijitKumarSingh
I am totally a noob, so I just want linux to remind me after say, 10 mins

Re: How to set a timer?

Posted: Mon Feb 22, 2021 9:54 am
by Welcome
You can use the sleep command. It uses seconds, so 10 minutes would be 600 seconds.

You can get fancy and add a sound or other notification.

Code: Select all

sleep 600 && paplay --volume 60000 /usr/share/sounds/freedesktop/stereo/phone-incoming-call.oga

Re: How to set a timer?

Posted: Mon Feb 22, 2021 9:55 am
by t42
I just want linux to remind me after say, 10 mins
You can install Gnome Clocks from the software manager or simply open terminal and paste this command

Code: Select all

sudo apt install gnome-clocks
14-57-30.png

Re: How to set a timer?

Posted: Mon Feb 22, 2021 10:07 am
by Welcome
t42 wrote:
Mon Feb 22, 2021 9:55 am
...
You can install Gnome Clocks from the software manager or simply open terminal and paste this command
...
Since this thread is in "Scripts & Bash", maybe OP is looking for a command line solution. :wink: OP did originally say...
I need to set a timer using the terminal, is there a way?

Re: How to set a timer?

Posted: Mon Feb 22, 2021 10:13 am
by t42
Welcome wrote:
Mon Feb 22, 2021 10:07 am

Since this thread is in "Scripts & Bash", maybe OP is looking for a command line solution. :wink..
Of course, thanks :)

Re: How to set a timer?

Posted: Mon Feb 22, 2021 10:31 am
by Welcome
This maybe a little complex, and doesn't include any error handling, but if you need a notification at a specific date and time, and must use a one-line bash command:

Code: Select all

sleep $(( $( date --date="27 Feb 2021 09:35:00" +%s ) - $( date +%s ) )) && paplay --volume 60000 /usr/share/sounds/freedesktop/stereo/phone-incoming-call.oga
You'd need to adjust the date and time in the command, of course.

Re: How to set a timer?

Posted: Mon Feb 22, 2021 10:37 pm
by freshminted
t42 wrote:
Mon Feb 22, 2021 9:55 am
You can install Gnome Clocks from the software manager or simply open terminal and paste this command

Code: Select all

sudo apt install gnome-clocks

14-57-30.png
This actually looked useful, so I installed it using

Code: Select all

sudo apt install gnome-clocks
. But I got a version without all the timer presets and looks like it's pretty ancient, version 3.28. What version are you running?

Re: How to set a timer?

Posted: Tue Feb 23, 2021 7:10 am
by t42
freshminted wrote:
Mon Feb 22, 2021 10:37 pm
But I got a version without all the timer presets and looks like it's pretty ancient, version 3.28. What version are you running?
It's version 3.36.2 from LM 20.1 . In fact, I like the old version more, it was simple just enough.

Re: How to set a timer?

Posted: Tue Feb 23, 2021 7:54 am
by AbhijitKumarSingh
I needed a bash script which I can change anytime so thanks.

Re: How to set a timer? [Solved]

Posted: Tue Feb 23, 2021 9:25 am
by 1000
Read about:
Cron
Anacron
Systemd timers

Maybe then you will know which one you want to use.
and maybe then you will have more questions.

Because we know too little about your project.

Re: How to set a timer? [Solved]

Posted: Tue Feb 23, 2021 12:18 pm
by 1000
Read also about
1. What is the difference between & and &&
2. About sleep command