0

I am using WSL (ubuntu 20.04) on my machine. Today I learned about the at command, which can be used for scheduling jobs. I attempted to use it on WSL but the job was not fired although its time came.

Can't we use this command on WSL?

If we can, what can be the problem?

Thank you.

mustafabaki
  • 95
  • 1
  • 5

1 Answers1

4

As with cron, the atd service is not started by default on WSL:

$ at now + 1 minute
warning: commands will be executed using /bin/sh
at> echo "Hello from at" > ~/at.log
at> <EOT>
job 1 at Thu Apr  7 08:02:00 2022
Can't open /var/run/atd.pid to signal atd. No atd running?

$ service atd status

  • atd is not running

but it may be started if you wish:

$ sudo service atd start
[sudo] password for steeldriver:
 * Starting deferred execution scheduler atd                                                                                                                         [ OK ]

then

$ at now + 1 minute
warning: commands will be executed using /bin/sh
at> echo "Hello from at" > $HOME/at.log
at> <EOT>
job 2 at Thu Apr  7 08:03:00 2022
$ atq
2       Thu Apr  7 08:03:00 2022 a steeldriver
$ atq

(queue is now empty)

$ cat ~/at.log
Hello from at
steeldriver
  • 136,215
  • 21
  • 243
  • 336