Linux Schedule

People schedule things for all sorts of reason. There’s school schedules, lunch schedules… I bet Iron Man has a schedule for cleaning his suit. Which makes me wonder, what does Iron Man do for a bathroom if he’s in the suit for a long time?

Anyway, back to scheduling. Suppose I want my computer to make a beep in two hours to remind me to go watch The Avengers.It’s very important that I start watching in two hours because I want to follow it up with The Avengers: Age of Ultron and then I want to go have dinner and see Infinity War.

The Avengers!

The Avengers!

I want my computer to make a beep in two hours. The first question is, how do I make my computer beep?

One way to do it is by this:

Alpha:~ computerlamp$ echo -en "\a"

 

That’s a lot to remember, isn’t it? Let’s use nano and make a file we’ll call beep.sh

Here’s a picture of me making the file:

Making beep.sh

Making beep.sh

Remember, when you save it, call it beep.sh

The next thing to do is to change the permissions on the file. We want this to be executable.

Alpha:~ computerlamp$ chmod 755 beep.sh

Now we’ve made our first shell script. A shell script is a computer program that executes shell commands in the order that they’re in the file. So if we run beep.sh like this:

Alpha:~ computerlamp$ ./beep.sh

 

we’ll get a beep! You’ve now written a computer program. How cool is that?

Now the next problem is how do we schedule this?

We use a program called at. I know, that’s a boring name. Now it’s 11 am and I want the computer to beep me at 1pm.

Alpha:~ computerlamp$ at -f /home/computerlamp/beep.sh 01:00PM

 

Now my computer knows that at 1PM it should run the program beep.sh, which means my computer will beep at me then.

How does this work? Well, there’s a daemon called atd that runs these jobs.

What if I want to run something every hour on the hour? I want to make my own cuckoo clock by making my computer beep at me every hour. We’ll talk about how tod o that next time.

20 thoughts on “Linux Schedule

Leave a Reply

Your email address will not be published. Required fields are marked *