DominusPi
Posts: 39
Joined: Mon Nov 18, 2013 5:31 pm

Tell the RPi to execute a command after a laps of time

Thu Jan 23, 2014 3:20 pm

Hey guys !

So I need to be able to execute any command after a short amount of time. What I imagine is something just like for the shutdown command, where you can put as an option to execute it after x minutes.

Is there an easy way for this ?

Thanks !
Cheers !

User avatar
RaTTuS
Posts: 10609
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Tell the RPi to execute a command after a laps of time

Thu Jan 23, 2014 3:34 pm

How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

DominusPi
Posts: 39
Joined: Mon Nov 18, 2013 5:31 pm

Re: Tell the RPi to execute a command after a laps of time

Thu Jan 23, 2014 4:07 pm

Thanks you !
Cheers !

Steven_Aldrich64
Posts: 4
Joined: Mon Jan 27, 2014 1:30 am

Re: Tell the RPi to execute a command after a laps of time

Mon Jan 27, 2014 4:51 am

Check out writing a Bash script. It is really easy to write a short script that would do this.

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Tell the RPi to execute a command after a laps of time

Tue Jan 28, 2014 9:21 pm

there are lots of choices for this depending on just what you want to do.

cron if you want it to run on a schedule (i.e. Every day at noon, 48 seconds after every hour, or 11:30 PM every Tuesday and Friday in June, August, and December)
at if you want to schedule it to run once, at a specified time
sleep [seconds] if you want to wait a given number of seconds and execute it at either the command line or in a shell script. (at the command line, you would for instance "sleep 60; echo "One minute elapsed. Shutting down." shutdown -h now" with the semicolon separating your commands.)

Return to “General discussion”