3

I use cron to schedule things in Linux, but recently I discovered the "at" command.

sudo apt-get install at

I don't understand the scope from which this command operates:

  • How would you schedule a command with at, that normally requires admin privileges?
  • What is the working directory (pwd) of a command scheduled with at?

Additionally, everything I've tried so far, didn't achieve what I was trying to do.

For example, I tried to launch gedit one minute from now:

echo "gedit" | at now + 1 minute

I waited a minute, and nothing happened.

I tried to turn off my monitor one minute from now:

echo "xset dpms force off" | at now + 1 minute

I waited a minute and nothing happened.

If I can't get "at" to reliably perform a task one minute from now, how can I be certain that it will perform something I tell it to do tomorrow and beyond?

What am I missing here?

v2r
  • 9,707
Lonnie Best
  • 2,244

1 Answers1

6

Try instead:

~$  at now + 1 minute
at> ls -ahl > /tmp/at_test
at> ^D

You will find /tmp/at_test after command executed.

If you want to run some GUI app you should specify DISPLAY variable; Use echo $DISPLAY to find out you display

~$  at now + 1 minute
at> DISPLAY=:0 gedit
at> ^D

Piping is also ok:

echo "DISPLAY=:0 gedit" | at now + 1 minute
Lonnie Best
  • 2,244
Dan
  • 6,784