我正在尝试使用PHP脚本创build作业,但是当执行作业时,似乎没有任何事情发生。 我试图输出任何错误logging文件,但没有运气。 似乎很明显,这是一个权限问题,因为当我设置Apache作为我的个人用户运行,一切工作正常。 然而,当我直接从PHP执行wget时,一切正常,所以似乎Apache有正确的权限来使用它。 这个问题似乎是在与Apache结合使用时。 所以我需要find一种方法来使这个工作与Apache作为自己的用户运行。
这是我正在使用的命令:
echo "wget -qO- http://example.com/" | at now + 1 minute 2>&1
有任何想法吗?
编辑:Apache可以创build在工作,似乎只是当他们执行任何事情正在发生。
你有没有检查apache用户是否在at.allow文件? 根据手册页…
The /etc/at.allow and /etc/at.deny files determine which user can sub- mit commands for later execution via at(1) or batch(1). The format of the files is a list of usernames, one on each line. Whitespace is not permitted. The superuser may always use at. If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at. If /etc/at.allow does not exist, /etc/at.deny is checked.
这个问题与cron类似:你的工作是在一个最小的环境下执行的(认为PATH = / bin:/ usr / bin和2或3个东西),没有任何东西附加到它的标准input和输出。
首先确保你的Apache账户是一个工作的shell(而不是/bin/false
),因为'at'会使用这个shell来运行你的jobspec。
然后尝试这个更具体的片段:
echo "/usr/bin/wget -qO- http://example.com/ >/tmp/example.com 2>/tmp/example.com.error" | at now + 1 minute