设置 cron 作业
拜托,我是 cron 作业的新手,最近才听说它。
问题是我正在尝试通过 phpscript 向自己发送消息。
我需要 cron 作业来读取 php 脚本并发送适当的消息。
这是我已经安装的 php 自助邮件程序。
<?php
$recipient = "*******@gmail.com";
$subject = "Flight Status";
$body = "Flight has just landed.";
if(mail($recipient, $subject, $body))
{
echo("<p>Message successfully sent</p>");
}
else
{
echo("<p>Message Delivery failed </p>");
}
?>
Please I am new to cron jobs and only heard of it recently.
The thing is I am trying to send a message to myself via a phpscript.
I need the cron job to read the php cript and send the appropriate message.
here is the php self mailer I have in place.
<?php
$recipient = "*******@gmail.com";
$subject = "Flight Status";
$body = "Flight has just landed.";
if(mail($recipient, $subject, $body))
{
echo("<p>Message successfully sent</p>");
}
else
{
echo("<p>Message Delivery failed </p>");
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 man 5 crontab 阅读 cron 手册。它也包含示例。
例如,
# 每个月第一天下午 2:15 运行 -- 输出邮寄至 paul
15 14 1 * * $HOME/bin/flight.php
you can read the manual for cron with man 5 crontab. It contain example as well.
for example,
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/flight.php
通过电话发送电子邮件很复杂,因为您需要设置 smtp 服务器。更好的解决方案是通过聊天应用程序向自己发送消息。
我个人使用 nimrod 来实现此目的: https://www.nimrod-messenger.io
它只是信使,但其他聊天系统也在计划中。
Sending email through phone is complicated, as you need a smtp server set up. A better solution would be to send yourself a message via a chat application.
I personally use nimrod for this : https://www.nimrod-messenger.io
It's messenger only but other chat systems are planned.