How to set a timer? [Solved]

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
AbhijitKumarSingh
Level 1
Level 1
Posts: 23
Joined: Fri Feb 12, 2021 7:02 am

How to set a timer? [Solved]

Post by AbhijitKumarSingh »

I need to set a timer using the terminal, is there a way?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
1000
Level 5
Level 5
Posts: 999
Joined: Wed Jul 29, 2020 2:14 am

Re: How to set a timer?

Post by 1000 »

Which timer?
User avatar
freshminted
Level 4
Level 4
Posts: 271
Joined: Fri May 01, 2020 12:26 am

Re: How to set a timer?

Post by freshminted »

Try the "at" command? You may have to install it first.
Complete World Domination within five years.
User avatar
AndyMH
Level 21
Level 21
Posts: 13504
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How to set a timer?

Post by AndyMH »

Do you mean a cron job?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
AbhijitKumarSingh
Level 1
Level 1
Posts: 23
Joined: Fri Feb 12, 2021 7:02 am

Re: How to set a timer?

Post by AbhijitKumarSingh »

I am totally a noob, so I just want linux to remind me after say, 10 mins
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: How to set a timer?

Post 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
Last edited by Welcome on Mon Feb 22, 2021 9:57 am, edited 1 time in total.
t42
Level 11
Level 11
Posts: 3689
Joined: Mon Jan 20, 2014 6:48 pm

Re: How to set a timer?

Post 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
-=t42=-
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: How to set a timer?

Post 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?
t42
Level 11
Level 11
Posts: 3689
Joined: Mon Jan 20, 2014 6:48 pm

Re: How to set a timer?

Post 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 :)
-=t42=-
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: How to set a timer?

Post 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.
User avatar
freshminted
Level 4
Level 4
Posts: 271
Joined: Fri May 01, 2020 12:26 am

Re: How to set a timer?

Post 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?
Complete World Domination within five years.
t42
Level 11
Level 11
Posts: 3689
Joined: Mon Jan 20, 2014 6:48 pm

Re: How to set a timer?

Post 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.
-=t42=-
AbhijitKumarSingh
Level 1
Level 1
Posts: 23
Joined: Fri Feb 12, 2021 7:02 am

Re: How to set a timer?

Post by AbhijitKumarSingh »

I needed a bash script which I can change anytime so thanks.
1000
Level 5
Level 5
Posts: 999
Joined: Wed Jul 29, 2020 2:14 am

Re: How to set a timer? [Solved]

Post 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.
1000
Level 5
Level 5
Posts: 999
Joined: Wed Jul 29, 2020 2:14 am

Re: How to set a timer? [Solved]

Post by 1000 »

Read also about
1. What is the difference between & and &&
2. About sleep command
Locked

Return to “Scripts & Bash”