Bosse_B
Posts: 1074
Joined: Thu Jan 30, 2014 9:53 am

Is at missing from Pi-OS?

Wed Aug 19, 2020 6:38 pm

I have read a number of sites describing how to run a process at a specific time using the at command.
I have tried it on my Ubuntu Server to schedule things that need to happen during the night.

Now turning towards the RaspberryPi I found to my astonishment that at is not recognized!

Code: Select all

$ at 01:45
-bash: at: command not found
This is on an RPi3B with PiOS installed a week or so ago (GUI with limited number of applications), so it is really up-to-date.
It is difficult to google at since it is such a common word, so I ask here instead.

What am I missing?
By what I read all how-tos just assume that at exists as part of Linux...
Bo Berglund
Sweden

GlowInTheDark
Posts: 1064
Joined: Sat Nov 09, 2019 12:14 pm

Re: Is at missing from Pi-OS?

Wed Aug 19, 2020 6:44 pm

Yes, it is not there by default. Surprised me, too.

But it is easily installable. apt-get install at

I have a list of missing packages that need to be installed onto a new Raspbian system. "at" is one of them.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

Bosse_B
Posts: 1074
Joined: Thu Jan 30, 2014 9:53 am

Re: Is at missing from Pi-OS?

Wed Aug 19, 2020 9:49 pm

Yep!

Code: Select all

sudo install at
did it!

Here is an at question:
I am trying to set a job at a time a few days ahead but it does not work properly..

Code: Select all

at 04:10
is supposed to set the job on the closest match in time, i.e. the following early morning.
And this works.
To set it on the next match all the tutorials I have seen say this is the command to add a day to the match:

Code: Select all

at 04:10 + 1 days
But in fact it is still set the following early morning.
If I do this I can set it on a date of my choosing:

Code: Select all

at 04:10 2020-08-31
and it works, but is overly clumsy.

Surprise:

Code: Select all

at 04:10 + 2 days
will actually move it to the night following next night.

How come there is an offset by 1?
It does NOT work as the descriptions online say it does...
But if I enter a command that will execute today if the offset is not added and I add one:

Code: Select all

at 23:49 + 1 days
THEN it moves the execution to the next day if I enter it before 23:49, i.e. now it obeys the rule....

How very confusing that the fact I am scheduling a job past midnight means I have to add 1 to the day offset in order to get it right.

Ideas?
Bo Berglund
Sweden

User avatar
davidcoton
Posts: 5483
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Is at missing from Pi-OS?

Wed Aug 19, 2020 10:58 pm

I don't use 'at', but one understanding of '+ n days' is: "pass midnight n times from now before activating at the set time". I think that is consistent with your observations.
Location: 345th cell on the right of the 210th row of L2 cache

GlowInTheDark
Posts: 1064
Joined: Sat Nov 09, 2019 12:14 pm

Re: Is at missing from Pi-OS?

Wed Aug 19, 2020 11:14 pm

Yeah, that's just the way "at" is. I like "at", and have used it for certain things, but the date syntax is weird.

You have to read the man page carefully and (still) do lots of experimentation/trial-and-error.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

Bosse_B
Posts: 1074
Joined: Thu Jan 30, 2014 9:53 am

Re: Is at missing from Pi-OS?

Thu Aug 20, 2020 10:31 am

davidcoton wrote:
Wed Aug 19, 2020 10:58 pm
I don't use 'at', but one understanding of '+ n days' is: "pass midnight n times from now before activating at the set time". I think that is consistent with your observations.
So the part that says +1 days really means +1 midnight.
If one is at 23:55 when doing

Code: Select all

at 00:10 +1 days
then the result is the same as at 00:10 without any days.
But if one is at 00:01 when issuing

Code: Select all

at 00:10 + 1 days
it will be set an extra day later...

The command should have been

Code: Select all

at 00:10 + 1 midnight
instead.

I assumed that + 1 days means + 24 hours from the closest match...
Bo Berglund
Sweden

GlowInTheDark
Posts: 1064
Joined: Sat Nov 09, 2019 12:14 pm

Re: Is at missing from Pi-OS?

Thu Aug 20, 2020 1:50 pm

As I said, the date syntax of "at" is weird, but, to quote fearless leader, it is what it is.
It is obviously not going to be changed.

A workaround that I've used is, that allows me to use the more flexible and familiar "GNU date format" for specifying a time, is to do something like:

$ at "$(date '+%whatever' -d 'your string here')"

where:

1) whatever is a format that is acceptable to "at" (you determine this by trial-and-error)
2) your string here is any format that is acceptable to GNU date - which is pretty darn good and intuitive.

Then of course you wrap the above in an alias or script or whatever and then everything is fine.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

Return to “Raspberry Pi OS”