[英]at command is not executed
我正在尝试使at
bash 命令运行,但它对我不起作用。 我可以将作业添加到队列中,但时间到时它不会运行。 我究竟做错了什么?
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 在 MacOS 11.5.2(或更早版本)中被删除
$ sudo find / -name atd -print 2>/dev/null
$
它工作正常。 只是使用at
运行的命令不会将其输出写入您调用它的终端。
尝试:
at now +2 minutes
echo TTTEEEST > new_file_test
您将在两分钟内看到该文件出现。
查看/var/at/jobs
并查看您的 at 工作是否在此处列出。 (它可能是基于操作系统的不同目录)。
默认情况下, at
大多数系统上未启用 at。 为了实际执行at
作业,必须执行atrun命令。
确切的机制因系统而异,因此您必须阅读at
、 atrun
等上的所有各种联机帮助页,以验证at
是否真的在您的系统上启用,以及您是否有权运行 at 作业。 您的系统上通常同时存在ant allow和ant deny文件,因此您需要同时检查这两个文件。 您必须既在允许文件中,又不在拒绝文件中。
最重要的是,您必须确保at
您的系统上甚至启用了 at (出于安全考虑,它通常被禁用)。
请查收你的邮件:
An at - or batch - command invoked from a su(1) shell will
retain the current userid. The user will be mailed standard
error and standard output from his commands, if any. Mail
will be sent using the command /usr/sbin/sendmail. If at is
executed from a su(1) shell, the owner of the login shell
will receive the mail.
我在这里找到了这个
首先使用如下命令确保 at 守护进程正在运行:
# ps -ef | grep atd root 8231 1 0 18:10 ? 00:00:00 /usr/sbin/atd
如果您没有看到 atd 正在运行,请使用以下命令启动它:
# /etc/init.d/atd start
要分析 at(d) 执行问题,它可能有助于
man at.allow
)systemctrl -a | grep atd
在 Ubuntu 上)tail -f /var/log/syslog
(在执行时)journalctl -b | grep atd
journalctl -b | grep atd
(发现here ,包含更多提示) “权限被拒绝”错误也可能是由于在 /etc/security/limits.conf 中定义的登录数量有限( at
运行用户)。
与at
命令一起使用时,我也遇到了与 echo 相同的问题。 但是,如果您尝试使用>
或>>
重定向输出,那么它会完美运行。 还可以尝试其他一些系统命令,例如reboot
、 ls > some_text_file
等,以确保 at 命令正常工作。 否则尝试sudo systemctl enable --now atd
at
守护进程中启用
结论第一: atrun
或者atd
守护进程没有运行,导致这个问题。
解决您的案例的指南:
man at
at
mannul。 就我而言,我(macos 10.13.6)发现了以下信息:Note that at is implemented through the launchd(8) daemon periodically invoking atrun(8), which is disabled by default. See atrun(8) for information about enabling atrun.
man atrun
检查atrun
mannul ,我发现:atrun 实用程序运行由 at(1) 排队的命令。 它由 com.apple.atrun.plist 属性列表中指定的 launchd(8) 定期调用。 默认情况下,属性列表包含设置为 true 的 Disabled 键,因此永远不会调用 atrun。
launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.