I am trying to make the at
bash command to run, but it is not working for me. I can add a job to the queue, but it is not run when the time is up. What am I doing wrong?
hpek@melda:~$ cat /usr/lib/cron/at.deny
hpek@melda:~$ atq
hpek@melda:~$ at now +2 minutes
echo TTTEEEST
job 12 at Sun May 6 02:09:00 2012
hpek@melda:~$ date
Sun May 6 02:10:24 CEST 2012
hpek@melda:~$ atq
12 Sun May 6 02:09:00 2012
hpek@melda:~$
UPD2021.08.06 atd was removed in MacOS 11.5.2 (or earlier)
$ sudo find / -name atd -print 2>/dev/null
$
The at command is a Linux command-line utility used to schedule a job for later execution. The utility reads commands from standard input and groups them into an at job, which executes only once. The alternative for at is a cron job. However, while at jobs execute only once, cron jobs are recurring events.
$() is a command substitution It turns out, $() is called a command substitution. The command in between $() or backticks (“) is run and the output replaces $() . It can also be described as executing a command inside of another command.
It is working fine. It's just that commands running with at
don't write their output to the terminal that you called it from.
Try:
at now +2 minutes
echo TTTEEEST > new_file_test
You'll see the file appear in two minutes.
Take a look at /var/at/jobs
and see if your at jobs are listed there. (It may be a different directory based upon OS).
By default, at
isn't enabled on most systems. In order for at
jobs to actually get executed, the atrun command must execute.
This command is executed either through launchd or through the cron depending upon the system.
The exact mechanisms are different from system to system, so you'll have to read all the various manpages on at
, atrun
, etc. to verify if at
is really enabled on your system, and whether you have permissions to run at jobs. There's normally both an ant allow and an ant deny file on your system, so you need to check both. You must be both in the allowed file, and also not in the deny file.
On top of that, you have to make sure that at
is even enabled on your system (due to security concerns, it is usually disabled).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With