我希望允许用户输入日期和时间以通过 PHP 发送群发电子邮件,尽管我认为最好使用 *nix 命令来触发 PHP 进程。我想知道 *nix 上是否有一种方法可以做到这一点,而无需添加每 15 分钟运行一次的 cronjob 来检查是否有大量电子邮件要发送。这并不是说这是一个密集的过程,但如果添加和管理 cronjob 会更漂亮。我认为这有点类似于 Windows 计划任务,它有一个结束日期,如果没有再次计划则设置为删除。
最佳答案
您正在寻找 at命令。
at [options] time [date]
Execute commands at a specified time and optional date. The commands are read from standard input or from a file. (See also batch.) End input with EOF. time can be formed either as a numeric hour (with optional minutes and modifiers) or as a keyword. It can contain an optional date, formed as a month and date, a day of the week, or a special keyword (today or tomorrow). An increment can also be specified.
The at command can always be issued by a privileged user. Other users must be listed in the file /etc/at.allow if it exists; otherwise, they must not be listed in /etc/at.deny. If neither file exists, only a privileged user can issue the command.
In typical usage, you run at and input commands that you want executed at a particular time, followed by EOF.
$ at 1:00 am tomorrow at> ./total_up > output at> mail joe < output at> Entered by pressing Ctrl-D job 1 at 2003-03-19 01:00
The two commands could also be placed in a file and submitted as follows:
$ at 1:00 am tomorrow < scriptfile
关于linux - 在 *nix 上有没有办法在未来的日期和时间触发进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/716782/